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.



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

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



12
13
14
15
# File 'lib/active_interactor/context/result.rb', line 12

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

.register_owner(owner) ⇒ Object



8
9
10
# File 'lib/active_interactor/context/result.rb', line 8

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

Instance Method Details

#to_hashObject Also known as: to_h



25
26
27
# File 'lib/active_interactor/context/result.rb', line 25

def to_hash
  @attributes.with_indifferent_access
end