Module: Settable
- Defined in:
- lib/settable.rb,
lib/settable/environment/env.rb,
lib/settable/environment/rails.rb
Overview
Settings module that can be easily included into classes that store your applications configuration.
Examples
$config = Settable.configure do
# basic set, similar to capistrano and sinatra
set :username, 'user'
set :password, 's3kr1t'
# namespace support to keep config clean
namespace :tracking do
set :enabled, true
end
set :block do
'blocks are allowed too!'
end
end
$config.username
# => 'user'
# Using presence methods, detect if theres a 'truthy' value
$config.username?
# => true
$config.tracking.enabled?
# => true
Defined Under Namespace
Modules: DSL, Environment Classes: Namespace, Setting, SettingBlock
Constant Summary collapse
- VERSION =
'3.0.3'- ROOT_NAMESPACE =
name of the top-level namespace when none is provided
:__settable__
Class Method Summary collapse
-
.configure(&block) ⇒ Object
Public: Standalone configuration helper.
- .included(base) ⇒ Object
Class Method Details
.configure(&block) ⇒ Object
Public: Standalone configuration helper.
block - The settings block.
Examples
$config = Settable.configure do
set :hello, 'world'
end
$config.hello
# => 'world'
Returns the settable object.
102 103 104 |
# File 'lib/settable.rb', line 102 def self.configure(&block) Namespace.new(ROOT_NAMESPACE, &block) end |
.included(base) ⇒ Object
84 85 86 |
# File 'lib/settable.rb', line 84 def self.included(base) base.extend DSL end |