Class: Jsoning::Version
- Inherits:
-
Object
- Object
- Jsoning::Version
- Defined in:
- lib/jsoning/foundations/version.rb
Overview
jsoning can output to conform to different versioning
Instance Attribute Summary collapse
-
#mappers ⇒ Object
readonly
Returns the value of attribute mappers.
-
#mappers_order ⇒ Object
readonly
Returns the value of attribute mappers_order.
-
#protocol ⇒ Object
readonly
the protocol class.
-
#version_name ⇒ Object
Returns the value of attribute version_name.
Instance Method Summary collapse
- #add_mapper(mapper) ⇒ Object
-
#initialize(protocol) ⇒ Version
constructor
A new instance of Version.
- #mapper_for(name) ⇒ Object
Constructor Details
#initialize(protocol) ⇒ Version
Returns a new instance of Version.
11 12 13 14 15 16 |
# File 'lib/jsoning/foundations/version.rb', line 11 def initialize(protocol) @protocol = protocol # mappers, only storing symbol of mapped values @mappers_order = [] @mappers = {} end |
Instance Attribute Details
#mappers ⇒ Object (readonly)
Returns the value of attribute mappers.
8 9 10 |
# File 'lib/jsoning/foundations/version.rb', line 8 def mappers @mappers end |
#mappers_order ⇒ Object (readonly)
Returns the value of attribute mappers_order.
9 10 11 |
# File 'lib/jsoning/foundations/version.rb', line 9 def mappers_order @mappers_order end |
#protocol ⇒ Object (readonly)
the protocol class
6 7 8 |
# File 'lib/jsoning/foundations/version.rb', line 6 def protocol @protocol end |
#version_name ⇒ Object
Returns the value of attribute version_name.
3 4 5 |
# File 'lib/jsoning/foundations/version.rb', line 3 def version_name @version_name end |
Instance Method Details
#add_mapper(mapper) ⇒ Object
24 25 26 27 28 |
# File 'lib/jsoning/foundations/version.rb', line 24 def add_mapper(mapper) raise Jsoning::Error, "Mapper must be of class Jsoning::Mapper" unless mapper.is_a?(Jsoning::Mapper) @mappers_order << canonical_mapper_name(mapper.name) @mappers[canonical_mapper_name(mapper.name)] = mapper end |
#mapper_for(name) ⇒ Object
30 31 32 |
# File 'lib/jsoning/foundations/version.rb', line 30 def mapper_for(name) @mappers[canonical_mapper_name(name)] end |