lib/ruby-conf.rb in ruby-conf-2.2.0 vs lib/ruby-conf.rb in ruby-conf-2.2.1

- old
+ new

@@ -26,12 +26,17 @@ @__rc_locked = true @__rc_attributes.each_value { |value| value.__rc_lock if value.is_a?(Config) } self end - def [](name, args = nil) + def [](name, args = []) value = @__rc_attributes[name.to_sym] - value.is_a?(Proc) ? __rc_root.instance_exec(*args, &value) : value + if value.is_a?(Proc) + args += [nil] * (value.arity.abs - args.size) if value.arity.abs > args.size + __rc_root.instance_exec(*args, &value) + else + value + end end def __rc_copy(o) if o.is_a?(Hash) o.inject({}) { |copy, (key, val)| copy[key] = __rc_copy(val); copy }