Sha256: 38e88bfa6e2e8df24fc7244b5e94cffa278cec7b4f340a2711b14105af86ceb4
Contents?: true
Size: 774 Bytes
Versions: 9
Compression:
Stored size: 774 Bytes
Contents
class NestedConfig # Evaluates a config value once replacing the original value # if the value responds to method +call+. # # == Example # # class MyConfig < NestedConfig # include NestedConfig::EvaluateOnce # end # # config = MyConfig.new # config.startup_time = proc { Time.now } # config.env = proc { |env| env.to_s.upcase } # # config.startup_time # => 2012-06-05 15:57:36 +0200 # config.startup_time # => 2012-06-05 15:57:36 +0200 # # config.env(:development) # => DEVELOPMENT # config.env # => DEVELOPMENT module EvaluateOnce def [](key, *args) value = super if value.respond_to?(:call) self[key] = value.call(*args) else value end end end end
Version data entries
9 entries across 9 versions & 1 rubygems