Class: ActiveInteractor::Context::Base
- Inherits:
-
Object
- Object
- ActiveInteractor::Context::Base
- Extended by:
- Type::DeclerationMethods::ClassMethods
- Includes:
- Type::DeclerationMethods, ActiveModel::Validations
- Defined in:
- lib/active_interactor/context/base.rb
Overview
The base class for all context objects
Constant Summary
Constants included from Type::DeclerationMethods
Type::DeclerationMethods::Boolean
Class Method Summary collapse
Instance Method Summary collapse
- #[](attribute_name) ⇒ Object
- #[]=(attribute_name, value) ⇒ Object
-
#initialize(attributes = {}) ⇒ Base
constructor
A new instance of Base.
Methods included from Type::DeclerationMethods::ClassMethods
Constructor Details
#initialize(attributes = {}) ⇒ Base
Returns a new instance of Base.
25 26 27 28 29 30 31 |
# File 'lib/active_interactor/context/base.rb', line 25 def initialize(attributes = {}) attribute_set.attributes.each do |attribute| next unless attributes.with_indifferent_access.key?(attribute.name) assign_attribute_value(attribute.name, attributes.with_indifferent_access[attribute.name]) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments) ⇒ Object (protected)
63 64 65 66 67 68 |
# File 'lib/active_interactor/context/base.rb', line 63 def method_missing(method_name, *arguments) return super unless respond_to_missing?(method_name) return assignment_method_missing(method_name, *arguments) if method_name.to_s.end_with?('=') read_attribute_value(method_name) end |
Class Method Details
.method_defined?(method_name) ⇒ Boolean
14 15 16 |
# File 'lib/active_interactor/context/base.rb', line 14 def method_defined?(method_name) attribute_set.attribute_names.include?(method_name.to_s.delete('=').to_sym) || super end |
Instance Method Details
#[](attribute_name) ⇒ Object
33 34 35 |
# File 'lib/active_interactor/context/base.rb', line 33 def [](attribute_name) read_attribute_value(attribute_name) end |
#[]=(attribute_name, value) ⇒ Object
37 38 39 |
# File 'lib/active_interactor/context/base.rb', line 37 def []=(attribute_name, value) assign_attribute_value(attribute_name, value) end |