Class: Proc

Inherits:
Object
  • Object
show all
Defined in:
lib/hawkular/operations/operations_api.rb

Overview

Adding a method ‘perform` for each block so that we can write nice callbacks for this client

Defined Under Namespace

Classes: PerformMethodMissing

Instance Method Summary collapse

Instance Method Details

#perform(callable, result) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/hawkular/operations/operations_api.rb', line 14

def perform(callable, result)
  call(Class.new do
    method_name = callable.to_sym
    define_method(method_name) { |&block| block.nil? ? true : block.call(result) }
    define_method("#{method_name}?") { true }
    define_method(:method_missing) { |*| PerformMethodMissing }
  end.new)
end