Class: PasswordRequired::ControllerConcern::ArgumentsComposer

Inherits:
Object
  • Object
show all
Defined in:
lib/password_required/controller_concern/arguments_composer.rb

Constant Summary collapse

VALID_KEYS =
[:for, :with]

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ ArgumentsComposer

Returns a new instance of ArgumentsComposer.



6
7
8
9
# File 'lib/password_required/controller_concern/arguments_composer.rb', line 6

def initialize(opts = {})
  @options = opts.slice(*VALID_KEYS)
  @options[:for] = Array(@options[:for])
end

Instance Method Details

#call(klass) ⇒ Object



11
12
13
14
15
# File 'lib/password_required/controller_concern/arguments_composer.rb', line 11

def call(klass)
  @options.each_pair do |key, value|
    send("handle_#{key}_key", klass, value, @options[:for])
  end
end