Sha256: 47b9ea59982e903989c5c19a736925e6139723cea43ea1b898f090a736185ca6
Contents?: true
Size: 782 Bytes
Versions: 10
Compression:
Stored size: 782 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_relation } 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
10 entries across 10 versions & 1 rubygems