Module: ActiveInteractor::Interactor::Context

Included in:
Base
Defined in:
lib/active_interactor/interactor/context.rb

Overview

Interactor context methods. Because Context is a module classes should include Context rather than inherit from it.

Author:

Since:

  • 0.1.0

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#context_attribute_missing(match, *args, &block) ⇒ Object

Call #attribute_missing on the interactor instance's context instance

Since:

  • 1.0.1



251
252
# File 'lib/active_interactor/interactor/context.rb', line 251

delegate :attribute_missing, :attribute_names, :fail!, :respond_to_without_attributes?, :rollback!,
to: :context, prefix: true

#context_attribute_namesObject

Call #attribute_names on the interactor instance's context instance

Since:

  • 1.0.1



251
252
# File 'lib/active_interactor/interactor/context.rb', line 251

delegate :attribute_missing, :attribute_names, :fail!, :respond_to_without_attributes?, :rollback!,
to: :context, prefix: true

#context_errorsObject

Call #errors on the interactor instance's context instance

Since:

  • 0.1.0



289
# File 'lib/active_interactor/interactor/context.rb', line 289

delegate(*ActiveModel::Validations.instance_methods, to: :context, prefix: true)

#context_fail!(errors = nil) ⇒ Object

Call #fail! on the interactor instance's context instance

Since:

  • 1.0.0



251
252
# File 'lib/active_interactor/interactor/context.rb', line 251

delegate :attribute_missing, :attribute_names, :fail!, :respond_to_without_attributes?, :rollback!,
to: :context, prefix: true

#context_invalid?(context = nil) ⇒ Object

Call #invalid? on the interactor instance's context instance

Since:

  • 0.1.0



289
# File 'lib/active_interactor/interactor/context.rb', line 289

delegate(*ActiveModel::Validations.instance_methods, to: :context, prefix: true)

#context_respond_to_without_attributes?(method, include_private_methods = false) ⇒ Object

Call #respond_to_without_attributes? on the interactor instance's context instance

Since:

  • 1.0.1



251
252
# File 'lib/active_interactor/interactor/context.rb', line 251

delegate :attribute_missing, :attribute_names, :fail!, :respond_to_without_attributes?, :rollback!,
to: :context, prefix: true

#context_rollback!Object

Call #rollback! on the interactor instance's context instance

Since:

  • 1.0.0



251
252
# File 'lib/active_interactor/interactor/context.rb', line 251

delegate :attribute_missing, :attribute_names, :fail!, :respond_to_without_attributes?, :rollback!,
to: :context, prefix: true

#context_valid?(context = nil) ⇒ Object

Call #valid? on the interactor instance's context instance

Since:

  • 0.1.0



289
# File 'lib/active_interactor/interactor/context.rb', line 289

delegate(*ActiveModel::Validations.instance_methods, to: :context, prefix: true)

#context_validate(context = nil) ⇒ Object

Call #validate on the interactor instance's context instance

Since:

  • 0.1.0



289
# File 'lib/active_interactor/interactor/context.rb', line 289

delegate(*ActiveModel::Validations.instance_methods, to: :context, prefix: true)

#context_validate!(context = nil) ⇒ Object

Call #validate! on the interactor instance's context instance

Since:

  • 0.1.0



289
# File 'lib/active_interactor/interactor/context.rb', line 289

delegate(*ActiveModel::Validations.instance_methods, to: :context, prefix: true)

#context_validates_absence_of(*attr_names) ⇒ Object

Call #validates_absence_of on the interactor instance's context instance

Since:

  • 0.1.0



350
# File 'lib/active_interactor/interactor/context.rb', line 350

delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context, prefix: true)

#context_validates_acceptance_of(*attr_names) ⇒ Object

Call #validates_acceptance_of on the interactor instance's context instance

Since:

  • 0.1.0



350
# File 'lib/active_interactor/interactor/context.rb', line 350

delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context, prefix: true)

#context_validates_confirmation_of(*attr_names) ⇒ Object

Call #validates_confirmation_of on the interactor instance's context instance

Since:

  • 0.1.0



350
# File 'lib/active_interactor/interactor/context.rb', line 350

delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context, prefix: true)

#context_validates_exclusion_of(*attr_names) ⇒ Object

Call #validates_exclusion_of on the interactor instance's context instance

Since:

  • 0.1.0



350
# File 'lib/active_interactor/interactor/context.rb', line 350

delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context, prefix: true)

#context_validates_format_of(*attr_names) ⇒ Object

Call #validates_format_of on the interactor instance's context instance

Since:

  • 0.1.0



350
# File 'lib/active_interactor/interactor/context.rb', line 350

delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context, prefix: true)

#context_validates_inclusion_of(*attr_names) ⇒ Object

Call #validates_inclusion_of on the interactor instance's context instance

Since:

  • 0.1.0



350
# File 'lib/active_interactor/interactor/context.rb', line 350

delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context, prefix: true)

#context_validates_length_of(*attr_names) ⇒ Object

Call #validates_length_of on the interactor instance's context instance

Since:

  • 0.1.0



350
# File 'lib/active_interactor/interactor/context.rb', line 350

delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context, prefix: true)

#context_validates_numericality_of(*attr_names) ⇒ Object

Call #validates_numericality_of on the interactor instance's context instance

Since:

  • 0.1.0



350
# File 'lib/active_interactor/interactor/context.rb', line 350

delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context, prefix: true)

#context_validates_presence_of(*attr_names) ⇒ Object

Call #validates_presence_of on the interactor instance's context instance

Since:

  • 0.1.0



350
# File 'lib/active_interactor/interactor/context.rb', line 350

delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context, prefix: true)

#context_validates_size_of(*attr_names) ⇒ Object

Call #validates_size_of on the interactor instance's context instance

Since:

  • 0.1.0



350
# File 'lib/active_interactor/interactor/context.rb', line 350

delegate(*ActiveModel::Validations::HelperMethods.instance_methods, to: :context, prefix: true)

#context_validates_with(*args, &block) ⇒ Object

Call #validates_with on the interactor instance's context instance

Since:

  • 0.1.0



289
# File 'lib/active_interactor/interactor/context.rb', line 289

delegate(*ActiveModel::Validations.instance_methods, to: :context, prefix: true)

#finalize_context!Class

Mark the interactor instance as called on the instance's context instance and return the context instance.

Returns:

Since:

  • 1.0.0



367
368
369
370
371
# File 'lib/active_interactor/interactor/context.rb', line 367

def finalize_context!
  context.called!(self)
  context.resolve
  context
end

#initialize(context = {}) ⇒ Base

Initialize a new instance of Base

Parameters:

  • context (Hash, Class) (defaults to: {})

    attributes to assign to the interactor instance's context instance

Returns:

Since:

  • 0.1.0



357
358
359
# File 'lib/active_interactor/interactor/context.rb', line 357

def initialize(context = {})
  @context = self.class.context_class.new(context)
end