Class: Bulletin::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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_withObject

Returns the value of attribute authenticate_with.



8
9
10
# File 'lib/bulletin/configuration.rb', line 8

def authenticate_with
  @authenticate_with
end

#job_queueObject

Returns the value of attribute job_queue.



8
9
10
# File 'lib/bulletin/configuration.rb', line 8

def job_queue
  @job_queue
end

#occurrence_capObject

Returns the value of attribute occurrence_cap.



8
9
10
# File 'lib/bulletin/configuration.rb', line 8

def occurrence_cap
  @occurrence_cap
end

#retentionObject

Returns the value of attribute retention.



9
10
11
# File 'lib/bulletin/configuration.rb', line 9

def retention
  @retention
end

#storeObject

Returns the value of attribute store.



9
10
11
# File 'lib/bulletin/configuration.rb', line 9

def store
  @store
end

#write_strategyObject

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.

Returns:

  • (Boolean)


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_cutoffObject



32
33
34
# File 'lib/bulletin/configuration.rb', line 32

def retention_cutoff
  Time.now - retention
end