Sha256: 198523db1021e58dea8d63c46aa9ec030d9d54945f9aaaa15c0fed0f20c55f42
Contents?: true
Size: 778 Bytes
Versions: 6
Compression:
Stored size: 778 Bytes
Contents
module PgSearch class Scope def initialize(name, model, scope_options_or_proc) @name = name @model = model @options_proc = build_options_proc(scope_options_or_proc) end def to_proc lambda { |*args| config = Configuration.new(@options_proc.call(*args), @model) ScopeOptions.new(@name, @model, config).to_hash } end private def build_options_proc(scope_options_or_proc) case scope_options_or_proc when Proc scope_options_or_proc when Hash lambda { |query| scope_options_or_proc.reverse_merge(:query => query) } else raise ArgumentError, "A PgSearch scope expects a Proc or Hash for its options" end end end end
Version data entries
6 entries across 6 versions & 1 rubygems