Class: Ransack::Configuration::PredicateCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/ransack/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePredicateCollection

Returns a new instance of PredicateCollection.



12
13
14
15
# File 'lib/ransack/configuration.rb', line 12

def initialize
  @collection = {}
  @sorted_names_with_underscores = []
end

Instance Attribute Details

#sorted_names_with_underscoresObject (readonly)

Returns the value of attribute sorted_names_with_underscores.



10
11
12
# File 'lib/ransack/configuration.rb', line 10

def sorted_names_with_underscores
  @sorted_names_with_underscores
end

Instance Method Details

#[]=(key, value) ⇒ Object



19
20
21
22
23
24
# File 'lib/ransack/configuration.rb', line 19

def []=(key, value)
  @sorted_names_with_underscores << [key, '_' + key]
  @sorted_names_with_underscores.sort! { |(a, _), (b, _)| b.length <=> a.length }

  @collection[key] = value
end