Module: Konfigurator
- Defined in:
- lib/konfigurator/dsl.rb,
lib/konfigurator.rb,
lib/konfigurator/simple.rb,
lib/konfigurator/railtie.rb,
lib/konfigurator/version.rb
Overview
Konfigurator::Simple is a configuration toolkit strongly inspired by Sinatra framework settings. Thanks to it you can easy implement configuration options to your apps, modules or classes. Take a look at simple example.
class MyClass do
set :foo, "bar"
enable :bar
disable :bla
configure :production do
enable :bla
set :spam, "eggs!"
end
end
Now you can get configured options directly from your class:
MyClass.foo # => "bar"
MyClass. # => true
MyClass.bla # => false
… or when current environment is set to :production
:
MyClass.bla # => true
MyClass.spam # => "eggs!"
All settings are also available from objects via #settings
method:
obj = MyObject.new
obj.settings.foo # => "bar"
obk.settings. # => true
Remember! when option is not set then NoMethodError
will be raised after try to get it direcly from class, eg:
MyObject.set :exist
MyObject.exist # => true
MyObject.not_exist # => will raise NoMethodError
Defined Under Namespace
Modules: Common, DSL, Helpers, Simple, Version
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
-
.version ⇒ Object
:nodoc:.
Class Method Details
.included(base) ⇒ Object
:nodoc:
8 9 10 11 |
# File 'lib/konfigurator.rb', line 8 def self.included(base) # :nodoc: # v0.0.1 compatibility... base.send(:include, Konfigurator::Simple) end |