Class: Jsoning::Version

Inherits:
Object
  • Object
show all
Defined in:
lib/jsoning/foundations/version.rb

Overview

jsoning can output to conform to different versioning

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#mappersObject (readonly)

Returns the value of attribute mappers.



8
9
10
# File 'lib/jsoning/foundations/version.rb', line 8

def mappers
  @mappers
end

#mappers_orderObject (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

#protocolObject (readonly)

the protocol class



6
7
8
# File 'lib/jsoning/foundations/version.rb', line 6

def protocol
  @protocol
end

#version_nameObject

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

Raises:



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