module ActiveInteractor::Configurable::ClassMethods

Configurable object class methods. Because {ClassMethods} is a module classes should extend {ClassMethods} rather than inherit from it.

@api private @author Aaron Allen <hello@aaronmallen.me> @since 1.0.0

Public Instance Methods

defaults(options = {}) click to toggle source

Get or Set the default attributes for a {Configurable} class. This method will create an `attr_accessor` on the configurable class as well as set a default value for the attribute.

@param options [Hash{Symbol=>*}, nil] the default options to set on the {Configurable} class @return [Hash{Symbol=>*}] the passed options or the set defaults if no options are passed.

# File lib/active_interactor/configurable.rb, line 29
def defaults(options = {})
  return __defaults if options.empty?

  options.each do |key, value|
    __defaults[key.to_sym] = value
    send(:attr_accessor, key.to_sym)
  end
end

Private Instance Methods

__defaults() click to toggle source
# File lib/active_interactor/configurable.rb, line 40
def __defaults
  @__defaults ||= {}
end