Module: Amount::Serialization
- Included in:
- Amount
- Defined in:
- lib/amount/serialization.rb
Overview
Versioned hash serialization. ‘include Serialization` does both halves: the instance side (`#to_h`) is mixed in directly, and the class-level entry point (`Amount.load`) is auto-extended onto the including class via the `included` hook below. The compact-string format is the responsibility of Parser.
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VERSION =
1
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
12 13 14 |
# File 'lib/amount/serialization.rb', line 12 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#to_h ⇒ Hash
46 47 48 49 50 51 52 |
# File 'lib/amount/serialization.rb', line 46 def to_h { v: VERSION, atomic: @atomic.to_s, symbol: @symbol.to_s } end |