Module: Ransack::Configuration

Included in:
Ransack
Defined in:
lib/ransack/configuration.rb

Instance Method Summary collapse

Instance Method Details

#add_predicate(name, opts = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ransack/configuration.rb', line 17

def add_predicate(name, opts = {})
  name = name.to_s
  opts[:name] = name
  compounds = opts.delete(:compounds)
  compounds = true if compounds.nil?
  compounds = false if opts[:wants_array]
  opts[:arel_predicate] = opts[:arel_predicate].to_s

  self.predicates[name] = Predicate.new(opts)

  ['_any', '_all'].each do |suffix|
    self.predicates[name + suffix] = Predicate.new(
      opts.merge(
        :name => name + suffix,
        :arel_predicate => opts[:arel_predicate] + suffix,
        :compound => true
      )
    )
  end if compounds
end

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



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

def configure
  yield self
end

#search_key=(name) ⇒ Object

default search_key that, it can be overridden on sort_link level



39
40
41
# File 'lib/ransack/configuration.rb', line 39

def search_key=(name)
  self.options[:search_key] = name
end