Class: DeltaCore::Snapshot
- Inherits:
-
Object
- Object
- DeltaCore::Snapshot
- Defined in:
- lib/delta_core/snapshot.rb
Constant Summary collapse
- FORMAT_VERSION =
1- VERSION_KEY =
"_v"
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(raw = nil) ⇒ Snapshot
constructor
A new instance of Snapshot.
- #serialize(current_state) ⇒ Object
Constructor Details
#initialize(raw = nil) ⇒ Snapshot
Returns a new instance of Snapshot.
10 11 12 |
# File 'lib/delta_core/snapshot.rb', line 10 def initialize(raw = nil) @state = parse(raw) end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
8 9 10 |
# File 'lib/delta_core/snapshot.rb', line 8 def state @state end |
Instance Method Details
#empty? ⇒ Boolean
14 15 16 |
# File 'lib/delta_core/snapshot.rb', line 14 def empty? @state.empty? end |
#serialize(current_state) ⇒ Object
18 19 20 21 22 |
# File 'lib/delta_core/snapshot.rb', line 18 def serialize(current_state) payload = { VERSION_KEY => FORMAT_VERSION } payload.merge!(stringify_keys(current_state)) JSON.generate(payload) end |