Class: ActionSet::FilterInstructions
- Inherits:
-
Object
- Object
- ActionSet::FilterInstructions
- Defined in:
- lib/action_set/filter_instructions.rb
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(params, set, controller) ⇒ FilterInstructions
constructor
A new instance of FilterInstructions.
Constructor Details
#initialize(params, set, controller) ⇒ FilterInstructions
Returns a new instance of FilterInstructions.
7 8 9 10 11 |
# File 'lib/action_set/filter_instructions.rb', line 7 def initialize(params, set, controller) @params = params @set = set @controller = controller end |
Instance Method Details
#get ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/action_set/filter_instructions.rb', line 13 def get instructions_hash = if form_friendly_complex_params? form_friendly_complex_params_to_hash elsif form_friendly_simple_params? form_friendly_simple_params_to_hash else @params end flattened_instructions = flatten_keys_of(instructions_hash).reject { |_, v| v.try(:empty?) } flattened_instructions.each_with_object({}) do |(keypath, value), memo| memo[keypath] = if value.respond_to?(:map) value.map { |v| AttributeValue.new(v).cast(to: klass_for_keypath(keypath, v, @set)) } else AttributeValue.new(value).cast(to: klass_for_keypath(keypath, value, @set)) end end end |