Class: Blocks::ProcWithArgs
- Inherits:
-
Object
- Object
- Blocks::ProcWithArgs
- Defined in:
- lib/blocks/proc_with_args.rb
Class Method Summary collapse
Class Method Details
.call(*args) ⇒ Object
3 4 5 6 7 |
# File 'lib/blocks/proc_with_args.rb', line 3 def self.call(*args) return nil unless args.present? v = args.shift v.is_a?(Proc) ? v.call(*(args[0, v.arity])) : v end |
.call_each_hash_value(*args) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/blocks/proc_with_args.rb', line 9 def self.call_each_hash_value(*args) = args.shift.presence || {} if .is_a?(Proc) call(, *args) else .inject({}) { |hash, (k, v)| hash[k] = call(v, *args); hash} end end |