Class: Service::Result

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::API, ActiveModel::Attributes
Defined in:
app/concerns/service.rb

Overview

ActiveSupport::Concern mixin: result.

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



49
50
51
# File 'app/concerns/service.rb', line 49

def [](key)
  to_hash[key.to_sym]
end

#to_hashObject Also known as: to_h

Hash compatibility — the old Virtus struct responded to [] and to_hash.
Callers that do result[:output], result.to_hash, or **result still work.
:params is excluded because it holds the internal attributes_used snapshot
and was never part of the public contract.



44
45
46
# File 'app/concerns/service.rb', line 44

def to_hash
  attributes.transform_keys(&:to_sym).except(:params)
end

#to_hash_with_paramsObject



53
54
55
# File 'app/concerns/service.rb', line 53

def to_hash_with_params
  attributes.transform_keys(&:to_sym)
end