Class: BBAttributeFilters::Handlers::Proc

Inherits:
Object
  • Object
show all
Defined in:
lib/bbattribute_filters/handlers/proc.rb

Overview

Handler which calls the proc within the scope of the evaluator

Instance Method Summary collapse

Constructor Details

#initialize(proc) ⇒ Proc

Returns a new instance of Proc.



8
9
10
11
12
13
14
# File 'lib/bbattribute_filters/handlers/proc.rb', line 8

def initialize(proc)
  unless proc.is_a?(::Proc)
    raise ArgumentError, 'BBAttributeFilters::Handlers::EvaluationHandler - Expected a Proc'
  end

  @proc = proc
end

Instance Method Details

#evaluate(evaluator) ⇒ Object



16
17
18
# File 'lib/bbattribute_filters/handlers/proc.rb', line 16

def evaluate(evaluator)
  evaluator.instance_exec(&@proc)
end