Class: Service::Result

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

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



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

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.



40
41
42
# File 'app/concerns/service.rb', line 40

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

#to_hash_with_paramsObject



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

def to_hash_with_params
  attributes.transform_keys(&:to_sym)
end