Class: Service::Result
- Inherits:
-
Object
- Object
- Service::Result
- Includes:
- ActiveModel::API, ActiveModel::Attributes
- Defined in:
- app/concerns/service.rb
Overview
ActiveSupport::Concern mixin: result.
Value object returned by services. Carries the service output plus
error details and HTTP-cache metadata (last_modified, etag).
Instance Method Summary collapse
-
#[](key) ⇒ Object?
Fetches a single attribute by name (Hash compatibility).
-
#to_hash ⇒ Hash{Symbol => Object}
(also: #to_h)
Hash compatibility — the old Virtus struct responded to [] and to_hash.
-
#to_hash_with_params ⇒ Hash{Symbol => Object}
Full attribute hash, including the internal
:paramssnapshot.
Instance Method Details
#[](key) ⇒ Object?
Fetches a single attribute by name (Hash compatibility).
72 73 74 |
# File 'app/concerns/service.rb', line 72 def [](key) to_hash[key.to_sym] end |
#to_hash ⇒ Hash{Symbol => Object} 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.
63 64 65 |
# File 'app/concerns/service.rb', line 63 def to_hash attributes.transform_keys(&:to_sym).except(:params) end |
#to_hash_with_params ⇒ Hash{Symbol => Object}
Full attribute hash, including the internal :params snapshot.
79 80 81 |
# File 'app/concerns/service.rb', line 79 def to_hash_with_params attributes.transform_keys(&:to_sym) end |