Class: WiserTrails::Config
- Inherits:
-
Object
- Object
- WiserTrails::Config
- Includes:
- Singleton
- Defined in:
- lib/wiser_trails/config.rb
Overview
Class used to initialize configuration object.
Defined Under Namespace
Classes: Block
Constant Summary collapse
- @@orm =
:active_record
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Returns the value of attribute enabled.
Class Method Summary collapse
-
.orm(orm = nil) ⇒ Object
Set the ORM for use by WiserTrails.
-
.orm=(orm = nil) ⇒ Object
alias for #orm.
-
.set(&block) ⇒ Object
Evaluates given block to provide DSL configuration.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#orm(orm = nil) ⇒ Object
instance version of #orm.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
11 12 13 14 |
# File 'lib/wiser_trails/config.rb', line 11 def initialize # Indicates whether WiserTrails is enabled globally @enabled = true end |
Instance Attribute Details
#enabled ⇒ Object
Returns the value of attribute enabled.
7 8 9 |
# File 'lib/wiser_trails/config.rb', line 7 def enabled @enabled end |
Class Method Details
.orm(orm = nil) ⇒ Object
Set the ORM for use by WiserTrails.
33 34 35 |
# File 'lib/wiser_trails/config.rb', line 33 def self.orm(orm = nil) @@orm = (orm ? orm.to_sym : false) || @@orm end |
.orm=(orm = nil) ⇒ Object
alias for #orm
39 40 41 |
# File 'lib/wiser_trails/config.rb', line 39 def self.orm=(orm = nil) orm(orm) end |
.set(&block) ⇒ Object
Evaluates given block to provide DSL configuration.
22 23 24 25 26 27 28 29 30 |
# File 'lib/wiser_trails/config.rb', line 22 def self.set &block b = Block.new b.instance_eval &block orm = b.instance_variable_get(:@orm) @@orm = orm unless orm.nil? enabled = b.instance_variable_get(:@en) instance instance.instance_variable_set(:@enabled, enabled) unless enabled.nil? end |
Instance Method Details
#orm(orm = nil) ⇒ Object
instance version of #orm
45 46 47 |
# File 'lib/wiser_trails/config.rb', line 45 def orm(orm=nil) self.class.orm(orm) end |