Module: ActiveInteractor::Context::Attributes::ClassMethods

Defined in:
lib/active_interactor/context/attributes.rb

Overview

Context attribute class methods extended by all Base

Since:

  • 0.1.4

Instance Method Summary collapse

Instance Method Details

#attributes(*attributes) ⇒ Array<Symbol>

Set or get attributes defined on the context class

Examples:

Set attributes on a context class

class MyInteractor::Context < ActiveInteractor::Context::Base
  attributes :first_name, :last_name
end

Get attributes defined on a context class

MyInteractor::Context.attributes
#=> [:first_name, :last_name]

Returns:

  • (Array<Symbol>)

    the defined attributes

Since:

  • 0.1.4


26
27
28
29
30
# File 'lib/active_interactor/context/attributes.rb', line 26

def attributes(*attributes)
  return __attributes if attributes.empty?

  @__attributes = __attributes.concat(attributes).compact.uniq.sort
end