Module: Roger::Helpers::GetCallable
Overview
Helper to include the get_callbable method
Instance Method Summary collapse
-
#get_callable(callable, map) ⇒ Object
Makes callable into a object that responds to call.
Instance Method Details
#get_callable(callable, map) ⇒ Object
Makes callable into a object that responds to call.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/roger/helpers/get_callable.rb', line 11 def get_callable(callable, map) return callable if callable.respond_to?(:call) callable = map[callable] if callable.is_a?(Symbol) && map.key?(callable) callable = callable.new if callable.is_a?(Class) if callable.respond_to?(:call) callable else = "Could not resolve #{callable.inspect}. Callable must" << "be an object that responds to #call or a symbol that resolve" << "to such an object or a class with a #call instance method." fail ArgumentError, end end |