Module: ActiveInteractor::Interactor::Context::ClassMethods
- Included in:
- Base
- Defined in:
- lib/active_interactor/interactor/context.rb
Overview
Interactor context class methods. Because ClassMethods is a module classes should extend ClassMethods rather than inherit from it.
Instance Method Summary collapse
-
#context_attribute(name, type = Type::Value.new, **options) ⇒ Object
Call .attribute on the interactor class' context class.
-
#context_attribute_method?(attribute) ⇒ Object
Call .attribute_method? on the interactor class' context class.
-
#context_attribute_missing(match, *args, &block) ⇒ Object
Call .attribute_missing on the interactor class' context class.
-
#context_attribute_names ⇒ Object
Call .attribute_names on the interactor class' context class.
-
#context_attributes(*attributes) ⇒ Object
Call .attributes on the interactor class' context class.
-
#context_class ⇒ Const
Get the interactor class' context class.
-
#context_clear_validators!(attribute) ⇒ Object
Call .clear_validators! on the interactor class' context class.
-
#context_respond_to_without_attributes?(method, include_private_methods = false) ⇒ Object
Call .respond_to_without_attributes? on the interactor class' context class.
-
#context_validate(*args, &block) ⇒ Object
Call .validate on the interactor class' context class.
-
#context_validates(*attributes) ⇒ Object
Call .validates on the interactor class' context class.
-
#context_validates!(*attributes) ⇒ Object
Call .validates! on the interactor class' context class.
-
#context_validates_absence_of(*attr_names) ⇒ Object
Call .validates_absence_of on the interactor class' context class.
-
#context_validates_acceptance_of(*attr_names) ⇒ Object
Call .validates_acceptance_of on the interactor class' context class.
-
#context_validates_confirmation_of(*attr_names) ⇒ Object
Call .validates_confirmation_of on the interactor class' context class.
-
#context_validates_each(*attr_names, &block) ⇒ Object
Call .validates_each on the interactor class' context class.
-
#context_validates_exclusion_of(*attr_names) ⇒ Object
Call .validates_exclusion_of on the interactor class' context class.
-
#context_validates_format_of(*attr_names) ⇒ Object
Call .validates_format_of on the interactor class' context class.
-
#context_validates_inclusion_of(*attr_names) ⇒ Object
Call .validates_inclusion_of on the interactor class' context class.
-
#context_validates_length_of(*attr_names) ⇒ Object
Call .validates_length_of on the interactor class' context class.
-
#context_validates_numericality_of(*attr_names) ⇒ Object
Call .validates_numericality_of on the interactor class' context class.
-
#context_validates_presence_of(*attr_names) ⇒ Object
Call .validates_presence_of on the interactor class' context class.
-
#context_validates_size_of(*attr_names) ⇒ Object
Call .validates_size_of on the interactor class' context class.
-
#context_validates_with(*args, &block) ⇒ Object
Call .validates_with on the interactor class' context class.
-
#context_validators ⇒ Object
Call .validators on the interactor class' context class.
-
#context_validators_on(*attributes) ⇒ Object
Call .validators_on on the interactor class' context class.
-
#contextualize_with(klass) ⇒ Const
Set the interactor class' context class.
Instance Method Details
#context_attribute(name, type = Type::Value.new, **options) ⇒ Object
Call .attribute on the interactor class' context class
66 |
# File 'lib/active_interactor/interactor/context.rb', line 66 delegate(*ActiveModel::Attributes::ClassMethods.instance_methods, to: :context_class, prefix: :context) |
#context_attribute_method?(attribute) ⇒ Object
Call .attribute_method? on the interactor class' context class
121 |
# File 'lib/active_interactor/interactor/context.rb', line 121 delegate(*ActiveModel::Validations::ClassMethods.instance_methods, to: :context_class, prefix: :context) |
#context_attribute_missing(match, *args, &block) ⇒ Object
Call .attribute_missing on the interactor class' context class
42 |
# File 'lib/active_interactor/interactor/context.rb', line 42 delegate :attributes, :attribute_missing, :respond_to_without_attributes?, to: :context_class, prefix: :context |
#context_attribute_names ⇒ Object
Call .attribute_names on the interactor class' context class
66 |
# File 'lib/active_interactor/interactor/context.rb', line 66 delegate(*ActiveModel::Attributes::ClassMethods.instance_methods, to: :context_class, prefix: :context) |
#context_attributes(*attributes) ⇒ Object
Call .attributes on the interactor class' context class
42 |
# File 'lib/active_interactor/interactor/context.rb', line 42 delegate :attributes, :attribute_missing, :respond_to_without_attributes?, to: :context_class, prefix: :context |
#context_class ⇒ Const
Get the interactor class' context class. If no class is found or no class is set via the #contextualize_with method a new class is created.
190 191 192 |
# File 'lib/active_interactor/interactor/context.rb', line 190 def context_class @context_class ||= ActiveInteractor::Context::Loader.find_or_create(self) end |
#context_clear_validators!(attribute) ⇒ Object
Call .clear_validators! on the interactor class' context class
121 |
# File 'lib/active_interactor/interactor/context.rb', line 121 delegate(*ActiveModel::Validations::ClassMethods.instance_methods, to: :context_class, prefix: :context) |
#context_respond_to_without_attributes?(method, include_private_methods = false) ⇒ Object
Call .respond_to_without_attributes? on the interactor class' context class
42 |
# File 'lib/active_interactor/interactor/context.rb', line 42 delegate :attributes, :attribute_missing, :respond_to_without_attributes?, to: :context_class, prefix: :context |
#context_validate(*args, &block) ⇒ Object
Call .validate on the interactor class' context class
121 |
# File 'lib/active_interactor/interactor/context.rb', line 121 delegate(*ActiveModel::Validations::ClassMethods.instance_methods, to: :context_class, prefix: :context) |
#context_validates(*attributes) ⇒ Object
Call .validates on the interactor class' context class
121 |
# File 'lib/active_interactor/interactor/context.rb', line 121 delegate(*ActiveModel::Validations::ClassMethods.instance_methods, to: :context_class, prefix: :context) |
#context_validates!(*attributes) ⇒ Object
Call .validates! on the interactor class' context class
121 |
# File 'lib/active_interactor/interactor/context.rb', line 121 delegate(*ActiveModel::Validations::ClassMethods.instance_methods, to: :context_class, prefix: :context) |
#context_validates_absence_of(*attr_names) ⇒ Object
Call .validates_absence_of on the interactor class' context class
182 |
# File 'lib/active_interactor/interactor/context.rb', line 182 delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context_class, prefix: :context) |
#context_validates_acceptance_of(*attr_names) ⇒ Object
Call .validates_acceptance_of on the interactor class' context class
182 |
# File 'lib/active_interactor/interactor/context.rb', line 182 delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context_class, prefix: :context) |
#context_validates_confirmation_of(*attr_names) ⇒ Object
Call .validates_confirmation_of on the interactor class' context class
182 |
# File 'lib/active_interactor/interactor/context.rb', line 182 delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context_class, prefix: :context) |
#context_validates_each(*attr_names, &block) ⇒ Object
Call .validates_each on the interactor class' context class
121 |
# File 'lib/active_interactor/interactor/context.rb', line 121 delegate(*ActiveModel::Validations::ClassMethods.instance_methods, to: :context_class, prefix: :context) |
#context_validates_exclusion_of(*attr_names) ⇒ Object
Call .validates_exclusion_of on the interactor class' context class
182 |
# File 'lib/active_interactor/interactor/context.rb', line 182 delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context_class, prefix: :context) |
#context_validates_format_of(*attr_names) ⇒ Object
Call .validates_format_of on the interactor class' context class
182 |
# File 'lib/active_interactor/interactor/context.rb', line 182 delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context_class, prefix: :context) |
#context_validates_inclusion_of(*attr_names) ⇒ Object
Call .validates_inclusion_of on the interactor class' context class
182 |
# File 'lib/active_interactor/interactor/context.rb', line 182 delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context_class, prefix: :context) |
#context_validates_length_of(*attr_names) ⇒ Object
Call .validates_length_of on the interactor class' context class
182 |
# File 'lib/active_interactor/interactor/context.rb', line 182 delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context_class, prefix: :context) |
#context_validates_numericality_of(*attr_names) ⇒ Object
Call .validates_numericality_of on the interactor class' context class
182 |
# File 'lib/active_interactor/interactor/context.rb', line 182 delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context_class, prefix: :context) |
#context_validates_presence_of(*attr_names) ⇒ Object
Call .validates_presence_of on the interactor class' context class
182 |
# File 'lib/active_interactor/interactor/context.rb', line 182 delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context_class, prefix: :context) |
#context_validates_size_of(*attr_names) ⇒ Object
Call .validates_size_of on the interactor class' context class
182 |
# File 'lib/active_interactor/interactor/context.rb', line 182 delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context_class, prefix: :context) |
#context_validates_with(*args, &block) ⇒ Object
Call .validates_with on the interactor class' context class
121 |
# File 'lib/active_interactor/interactor/context.rb', line 121 delegate(*ActiveModel::Validations::ClassMethods.instance_methods, to: :context_class, prefix: :context) |
#context_validators ⇒ Object
Call .validators on the interactor class' context class
121 |
# File 'lib/active_interactor/interactor/context.rb', line 121 delegate(*ActiveModel::Validations::ClassMethods.instance_methods, to: :context_class, prefix: :context) |
#context_validators_on(*attributes) ⇒ Object
Call .validators_on on the interactor class' context class
121 |
# File 'lib/active_interactor/interactor/context.rb', line 121 delegate(*ActiveModel::Validations::ClassMethods.instance_methods, to: :context_class, prefix: :context) |
#contextualize_with(klass) ⇒ Const
Set the interactor class' context class
212 213 214 215 216 217 218 219 |
# File 'lib/active_interactor/interactor/context.rb', line 212 def contextualize_with(klass) @context_class = begin context_class = klass.to_s.camelize.safe_constantize raise(ActiveInteractor::Error::InvalidContextClass, klass) unless context_class context_class end end |