Class: PublicActivity::Config
- Inherits:
-
Object
- Object
- PublicActivity::Config
- Includes:
- Singleton
- Defined in:
- lib/public_activity/config.rb
Overview
Class used to initialize configuration object.
Defined Under Namespace
Classes: Block
Class Method Summary collapse
- .enabled(value = nil) ⇒ Object
-
.enabled=(value = nil) ⇒ Object
alias for #enabled.
-
.orm(orm = nil) ⇒ Object
Set the ORM for use by PublicActivity.
-
.orm=(orm = nil) ⇒ Object
alias for #orm.
-
.set(&block) ⇒ Object
Evaluates given block to provide DSL configuration.
- .table_name(name = nil) ⇒ Object
Instance Method Summary collapse
-
#enabled(value = nil) ⇒ Object
instance version of #enabled.
-
#orm(orm = nil) ⇒ Object
instance version of #orm.
-
#table_name(name = nil) ⇒ Object
instance version of #table_name.
Class Method Details
.enabled(value = nil) ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/public_activity/config.rb', line 73 def self.enabled(value = nil) if value.nil? val = Thread.current[:public_activity_enabled] val.nil? ? true : val else Thread.current[:public_activity_enabled] = value end end |
.enabled=(value = nil) ⇒ Object
alias for #enabled
34 35 36 |
# File 'lib/public_activity/config.rb', line 34 def self.enabled=(value = nil) enabled(value) end |
.orm(orm = nil) ⇒ Object
Set the ORM for use by PublicActivity.
57 58 59 60 61 62 63 |
# File 'lib/public_activity/config.rb', line 57 def self.orm(orm = nil) if orm.nil? Thread.current[:public_activity_orm] || :active_record else Thread.current[:public_activity_orm] = orm.to_sym end end |
.orm=(orm = nil) ⇒ Object
alias for #orm
28 29 30 |
# File 'lib/public_activity/config.rb', line 28 def self.orm=(orm = nil) orm(orm) end |
.set(&block) ⇒ Object
Evaluates given block to provide DSL configuration.
17 18 19 20 21 22 23 24 |
# File 'lib/public_activity/config.rb', line 17 def self.set(&block) b = Block.new b.instance_eval(&block) instance orm(b.orm) unless b.orm.nil? enabled(b.enabled) unless b.enabled.nil? table_name(b.table_name) unless b.table_name.nil? end |
.table_name(name = nil) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/public_activity/config.rb', line 65 def self.table_name(name = nil) if name.nil? Thread.current[:public_activity_table_name] || "activities" else Thread.current[:public_activity_table_name] = name end end |
Instance Method Details
#enabled(value = nil) ⇒ Object
instance version of #enabled
52 53 54 |
# File 'lib/public_activity/config.rb', line 52 def enabled(value = nil) self.class.enabled(value) end |
#orm(orm = nil) ⇒ Object
instance version of #orm
40 41 42 |
# File 'lib/public_activity/config.rb', line 40 def orm(orm = nil) self.class.orm(orm) end |
#table_name(name = nil) ⇒ Object
instance version of #table_name
46 47 48 |
# File 'lib/public_activity/config.rb', line 46 def table_name(name = nil) self.class.table_name(name) end |