module Confo

Constants

VERSION

Public Class Methods

call(object, method, *args)
call_method_with_floating_arguments(object, method, *args) click to toggle source
# File lib/confo.rb, line 34
def call_method_with_floating_arguments(object, method, *args)
  callable      = object.method(method)
  arity         = callable.arity
  resized_args  = arity < 0 ? args : args[0...arity]
  callable.call(*resized_args)
end
Also aliased as: call
callable_without_arguments?(obj) click to toggle source
# File lib/confo.rb, line 20
def callable_without_arguments?(obj)
  obj.respond_to?(:call) && (!obj.respond_to?(:arity) || obj.arity == 0)
end
convert_to_hash(value) click to toggle source
# File lib/confo.rb, line 24
def convert_to_hash(value)
  if value.respond_to?(:to_hash)
    value.to_hash
  elsif value.is_a?(Array)
    value.map { |e| convert_to_hash(e) }
  else
    value
  end
end
result_of(value, *args) click to toggle source
# File lib/confo.rb, line 11
def result_of(value, *args)
  if value.respond_to?(:call)
    _args_ = value.arity < 0 ? args : args[0...value.arity]
    value.call(*args)
  else
    value
  end
end