Class: Proc
- Inherits:
-
Object
- Object
- Proc
- 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
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/hawkular/operations/operations_api.rb', line 11 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 } # method_missing is here because we are not forcing the client to provide both success and error callbacks # rubocop:disable Lint/NestedMethodDefinition # https://github.com/bbatsov/rubocop/issues/2704 def method_missing(_method_name, *_args, &_block) PerformMethodMissing end # rubocop:enable Lint/NestedMethodDefinition end.new) end |