Class: Dynamometer::Parameters

Inherits:
ActionController::Parameters
  • Object
show all
Defined in:
lib/dynamometer/parameters.rb

Instance Method Summary collapse

Instance Method Details

#hash_filter(params, filter) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/dynamometer/parameters.rb', line 4

def hash_filter(params, filter)
  filter = filter.with_indifferent_access
  # this is tricky - we grab the :dynamic_attributes key from params
  # and use it to check the rest of our keys
  #
  if filter.has_key?('dynamic_attributes')
    model = filter.delete('dynamic_attributes')
    self.keys.each do |key|
      # if the key is already in params it's OK
      next if params[key] || !model.permitted_dynamic_attribute?(key)
      permitted_scalar_filter(params, key)
    end
  end
  super(params, filter)
end