Class: ActiveInteractor::Context::Base

Inherits:
Object
  • Object
show all
Includes:
AttributeAssignment, AttributeRegistration, HasActiveModelErrors, Type::HasTypes, ActiveModel::Validations
Defined in:
lib/active_interactor/context/base.rb

Direct Known Subclasses

Input, Output, Runtime

Constant Summary

Constants included from Type::HasTypes

Type::HasTypes::Boolean

Instance Attribute Summary

Attributes included from HasActiveModelErrors

#errors

Instance Method Summary collapse

Methods included from AttributeAssignment

#[], #[]=

Methods included from HasActiveModelErrors

#read_attribute_for_validation

Constructor Details

#initialize(attributes = {}) ⇒ Base

Returns a new instance of Base.



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

def initialize(attributes = {})
  super
  @errors = ActiveModel::Errors.new(self)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveInteractor::Context::AttributeAssignment

Instance Method Details

#validate!Object



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

def validate!
  attribute_set.attributes.each do |attribute|
    attribute.validate!
    attribute.error_messages.each { |message| errors.add(attribute.name, message) }
  end
end