Class: FlossFunding::ActivationEvent
- Inherits:
-
Object
- Object
- FlossFunding::ActivationEvent
- Defined in:
- lib/floss_funding/activation_event.rb
Overview
Represents a single funding-related activation event for a Library.
Tracks mutable state across: “activated”, “unactivated”, and “invalid”.
Instance Attribute Summary collapse
-
#activation_key ⇒ String
readonly
-
#library ⇒ FlossFunding::Library
readonly
-
#occurred_at ⇒ Time
readonly
-
#silent ⇒ Object?
readonly
Flag or callable indicating silent preference.
-
#state ⇒ String
One of STATE_VALUES.
Instance Method Summary collapse
-
#initialize(library, activation_key, state, silent) ⇒ ActivationEvent
constructor
A new instance of ActivationEvent.
-
#validate! ⇒ Object
Constructor Details
#initialize(library, activation_key, state, silent) ⇒ ActivationEvent
Returns a new instance of ActivationEvent.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/floss_funding/activation_event.rb', line 22 def initialize(library, activation_key, state, silent) @library = library @activation_key = activation_key @state = state # has already been normalized by FlossFunding::Inclusion # Always use the deterministic time source from FlossFunding @occurred_at = ::FlossFunding.loaded_at @silent = silent validate! freeze end |
Instance Attribute Details
#activation_key ⇒ String (readonly)
10 11 12 |
# File 'lib/floss_funding/activation_event.rb', line 10 def activation_key @activation_key end |
#library ⇒ FlossFunding::Library (readonly)
8 9 10 |
# File 'lib/floss_funding/activation_event.rb', line 8 def library @library end |
#occurred_at ⇒ Time (readonly)
14 15 16 |
# File 'lib/floss_funding/activation_event.rb', line 14 def occurred_at @occurred_at end |
#silent ⇒ Object? (readonly)
Returns flag or callable indicating silent preference.
16 17 18 |
# File 'lib/floss_funding/activation_event.rb', line 16 def silent @silent end |
#state ⇒ String
Returns one of STATE_VALUES.
12 13 14 |
# File 'lib/floss_funding/activation_event.rb', line 12 def state @state end |
Instance Method Details
#validate! ⇒ Object
33 34 35 36 |
# File 'lib/floss_funding/activation_event.rb', line 33 def validate! raise FlossFunding::Error, "#{@state.inspect} (#{@state.class}) must be one of #{STATE_VALUES}" unless STATE_VALUES.include?(@state) raise FlossFunding::Error, "silent must be nil or respond to call (silent=true short circuits)" unless @silent.nil? || @silent.respond_to?(:call) end |