Module: CallWithParams
- Defined in:
- lib/call_with_params.rb
Instance Method Summary collapse
Instance Method Details
#call_each_hash_value_with_params(*args) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/call_with_params.rb', line 8 def call_each_hash_value_with_params(*args) return {} if args.empty? = args.shift || {} if .is_a?(Proc) call_with_params(, *args) else .inject(HashWithIndifferentAccess.new) { |hash, (k, v)| hash[k] = call_with_params(v, *args); hash} end end |
#call_with_params(*args) ⇒ Object
2 3 4 5 6 |
# File 'lib/call_with_params.rb', line 2 def call_with_params(*args) return nil if args.empty? v = args.shift v.is_a?(Proc) ? v.call(*(args[0, v.arity])) : v end |