Class: Bulletin::Configuration
- Inherits:
-
Object
- Object
- Bulletin::Configuration
- Defined in:
- lib/bulletin/configuration.rb
Overview
Host-facing configuration. Sensible dev-first defaults; the seams that matter for a future production story (store backend, write strategy) are decoupled so they can evolve independently.
Instance Attribute Summary collapse
-
#authenticate_with ⇒ Object
Returns the value of attribute authenticate_with.
-
#job_queue ⇒ Object
Returns the value of attribute job_queue.
-
#occurrence_cap ⇒ Object
Returns the value of attribute occurrence_cap.
-
#retention ⇒ Object
Returns the value of attribute retention.
-
#store ⇒ Object
Returns the value of attribute store.
-
#write_strategy ⇒ Object
Returns the value of attribute write_strategy.
Instance Method Summary collapse
- #enabled=(value) ⇒ Object
-
#enabled? ⇒ Boolean
Whether Bulletin should record at all.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #retention_cutoff ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
11 12 13 14 15 16 17 18 19 |
# File 'lib/bulletin/configuration.rb', line 11 def initialize @store = :active_record # :active_record | :null (seam for :redis/:hybrid) @write_strategy = :active_job # :active_job | :inline @job_queue = :bulletin @retention = 7 * 24 * 60 * 60 # seconds; coerced from Durations too @occurrence_cap = 50 # max occurrence rows kept per issue @enabled = nil # nil => follow Bullet.enable? @authenticate_with = nil # ->(request) { ... } ; nil => dev-only access end |
Instance Attribute Details
#authenticate_with ⇒ Object
Returns the value of attribute authenticate_with.
8 9 10 |
# File 'lib/bulletin/configuration.rb', line 8 def authenticate_with @authenticate_with end |
#job_queue ⇒ Object
Returns the value of attribute job_queue.
8 9 10 |
# File 'lib/bulletin/configuration.rb', line 8 def job_queue @job_queue end |
#occurrence_cap ⇒ Object
Returns the value of attribute occurrence_cap.
8 9 10 |
# File 'lib/bulletin/configuration.rb', line 8 def occurrence_cap @occurrence_cap end |
#retention ⇒ Object
Returns the value of attribute retention.
9 10 11 |
# File 'lib/bulletin/configuration.rb', line 9 def retention @retention end |
#store ⇒ Object
Returns the value of attribute store.
9 10 11 |
# File 'lib/bulletin/configuration.rb', line 9 def store @store end |
#write_strategy ⇒ Object
Returns the value of attribute write_strategy.
8 9 10 |
# File 'lib/bulletin/configuration.rb', line 8 def write_strategy @write_strategy end |
Instance Method Details
#enabled=(value) ⇒ Object
44 45 46 |
# File 'lib/bulletin/configuration.rb', line 44 def enabled=(value) @enabled = value end |
#enabled? ⇒ Boolean
Whether Bulletin should record at all. Defaults to Bullet’s own switch so it inherits Bullet’s dev/staging-only posture unless explicitly overridden.
38 39 40 41 42 |
# File 'lib/bulletin/configuration.rb', line 38 def enabled? return defined?(Bullet) && Bullet.enable? if @enabled.nil? @enabled.respond_to?(:call) ? !!@enabled.call : !!@enabled end |
#retention_cutoff ⇒ Object
32 33 34 |
# File 'lib/bulletin/configuration.rb', line 32 def retention_cutoff Time.now - retention end |