Class: Birddog::ScopeBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/birddog/scope_builder.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, scope_options) ⇒ ScopeBuilder

Returns a new instance of ScopeBuilder.



9
10
11
12
# File 'lib/birddog/scope_builder.rb', line 9

def initialize(model, scope_options)
  @options = scope_options
  @model = model
end

Class Method Details

.build(model, scope_options) ⇒ Object



5
6
7
# File 'lib/birddog/scope_builder.rb', line 5

def self.build(model, scope_options)
  new(model, scope_options).build
end

Instance Method Details

#buildObject



14
15
16
17
18
19
20
21
22
# File 'lib/birddog/scope_builder.rb', line 14

def build
  scope = @model.scoped
  
  @options.each do |k, v|
    scope = scope.__send__(k, v)
  end
  
  return scope
end