Class: PgSearch::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/pg_search/scope.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, model, scope_options_or_proc) ⇒ Scope

Returns a new instance of Scope.



3
4
5
6
7
# File 'lib/pg_search/scope.rb', line 3

def initialize(name, model, scope_options_or_proc)
  @name = name
  @model = model
  @options_proc = build_options_proc(scope_options_or_proc)
end

Instance Method Details

#to_procObject



9
10
11
12
13
14
# File 'lib/pg_search/scope.rb', line 9

def to_proc
  lambda { |*args|
    config = Configuration.new(@options_proc.call(*args), @model)
    ScopeOptions.new(@name, @model, config).to_relation
  }
end