Class: ActiveInteractor::Context::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/active_interactor/context/result.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Result

Returns a new instance of Result.



19
20
21
22
23
24
25
# File 'lib/active_interactor/context/result.rb', line 19

def initialize(attributes = {})
  @attributes = {}
  attributes.each_pair do |key, value|
    instance_variable_set(:"@#{key}", value)
    @attributes[key] = value
  end
end

Class Method Details

.for_output_context(owner, context) ⇒ Object



14
15
16
17
# File 'lib/active_interactor/context/result.rb', line 14

def self.for_output_context(owner, context)
  context.fields.each_key { |field| owner::ResultContext.send(:attr_reader, field) }
  owner::ResultContext.new(context.fields.deep_dup)
end

.register_owner(owner) ⇒ Object



10
11
12
# File 'lib/active_interactor/context/result.rb', line 10

def self.register_owner(owner)
  owner.const_set(:ResultContext, Class.new(self))
end

Instance Method Details

#to_hashObject Also known as: to_h



27
28
29
# File 'lib/active_interactor/context/result.rb', line 27

def to_hash
  @attributes.with_indifferent_access
end