Created
January 19, 2010 03:54
-
-
Save stephencelis/280650 to your computer and use it in GitHub Desktop.
Revisions
-
stephencelis revised this gist
Jan 19, 2010 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -38,7 +38,7 @@ def method_missing(method, *args) super if (key = method.to_s).end_with?("=") boolean = key.chomp!("?") value = self[key] value = value.call(*args) if value.respond_to?(:call) boolean ? !!value : value end -
stephencelis revised this gist
Jan 19, 2010 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ # # config/app/development.rb # config.key = "devalue" # # App.key # => "devalue" class Configuration autoload :OpenStruct, "ostruct" -
stephencelis created this gist
Jan 19, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ # Define application-level configuration using a simple DSL. # # class App < Configuration # config.key = "value" # config.lazy = lambda { |load| load } # end # # App.key # => "value" # App.key? # => true # App.lazy("load") # => "load" # App.lazy?(nil) # => false # # Override by Rails environment. # # # config/app/development.rb # config.key = "devalue" # # App.key # => "value" class Configuration autoload :OpenStruct, "ostruct" class << self def [](key) config.send key end def inspect config.inspect.sub config.class.name, name end private def config @config ||= OpenStruct.new end def method_missing(method, *args) super if (key = method.to_s).end_with?("=") boolean = key.chomp!("?") value = self[key] value = value.respond_to?(:call) ? value.call(*args) : value boolean ? !!value : value end def inherited(subclass) return unless defined? Rails config = "#{Rails.root}/config/#{name.underscore}/#{Rails.env}.rb" if File.exist?(config) eval File.read(config), binding, __FILE__, __LINE__ end end end end