Module: ExtendedHasEnumeration::AggregateConditionsOverride

Defined in:
lib/extended_has_enumeration/aggregate_conditions_override.rb

Instance Method Summary collapse

Instance Method Details

#expand_hash_conditions_for_aggregates(attrs) ⇒ Object

Override the aggregate hash conditions behavior to coerce has_enumeration attributes that show up in finder options as symbols into instances of the aggregate class before hash expansion.



6
7
8
9
10
11
12
13
14
# File 'lib/extended_has_enumeration/aggregate_conditions_override.rb', line 6

def expand_hash_conditions_for_aggregates(attrs)
  expanded_attrs = attrs.dup
  attr_enumeration_mapping_classes.each do |attr, klass|
    if expanded_attrs[attr].is_a?(Symbol)
      expanded_attrs[attr] = klass.from_sym(expanded_attrs[attr])
    end
  end
  super(expanded_attrs)
end