Class: ParamsModifier::Base
- Inherits:
-
Object
- Object
- ParamsModifier::Base
- Defined in:
- lib/params_modifier/base.rb
Overview
Base class for params modifier
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(attributes) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(attributes) ⇒ Base
Returns a new instance of Base.
8 9 10 |
# File 'lib/params_modifier/base.rb', line 8 def initialize(attributes) @attributes = attributes end |
Class Method Details
.parameter(param_name, &block) ⇒ Object
4 5 6 |
# File 'lib/params_modifier/base.rb', line 4 def self.parameter(param_name, &block) define_method "_parameter_#{param_name}".to_sym, &block end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 |
# File 'lib/params_modifier/base.rb', line 12 def call @attributes.each do |key, value| method_name = "_parameter_#{key}" @attributes[key] = send(method_name, value) if respond_to?(method_name) end end |