Class: NiftyScope::Scope

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

Instance Method Summary collapse

Constructor Details

#initialize(scope, params, options) ⇒ Scope

Returns a new instance of Scope.



5
6
7
8
9
# File 'lib/nifty_scope/scope.rb', line 5

def initialize(scope, params, options)
  @scope = scope
  @mapping = options[:mapping] || {}
  @params = filter(params, options)
end

Instance Method Details

#applyObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/nifty_scope/scope.rb', line 11

def apply
  @params.each do |key, value|
    scope_method = scope_method_for(key.to_sym)
    ensure_scope_responds_to(scope_method)

    @scope = eval_scope(scope_method, value)
  end

  @scope
end