Module: Ransack::Configuration

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

Instance Method Summary collapse

Instance Method Details

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



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ransack/configuration.rb', line 14

def add_predicate(name, opts = {})
  name = name.to_s
  opts[:name] = name
  compounds = opts.delete(:compounds)
  compounds = true if compounds.nil?
  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:



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

def configure
  yield self
end