Class: Dredd::Dsl::Predicate

Inherits:
Object
  • Object
show all
Defined in:
lib/dredd/dsl/predicate.rb

Constant Summary collapse

MAP =
{
  :is => :==,
  :lt => :<,
  :gt => :>
}

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/dredd/dsl/predicate.rb', line 15

def method_missing(meth, *args, &block)
  if [:is, :lt, :gt].include?(meth)
    @func = [MAP[meth], *args]
  else
    super
  end
end

Instance Method Details

#execute(val) ⇒ Object



9
10
11
12
# File 'lib/dredd/dsl/predicate.rb', line 9

def execute(val)
  return val unless @func 
  return val.send(*@func)
end