Sha256: 798b1c56e443a0f573d1c316970bb886e9e53484c2821e9354a13c7cb9f93096
Contents?: true
Size: 880 Bytes
Versions: 4
Compression:
Stored size: 880 Bytes
Contents
require 'ransack/constants' require 'ransack/predicate' module Ransack module Configuration mattr_accessor :predicates self.predicates = {} def self.predicate_keys predicates.keys.sort {|a,b| b.length <=> a.length} end def configure yield self end 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 end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ransack-0.3.0 | lib/ransack/configuration.rb |
ransack-0.2.1 | lib/ransack/configuration.rb |
ransack-0.2.0 | lib/ransack/configuration.rb |
ransack-0.1.0 | lib/ransack/configuration.rb |