Class: SMG::Mapping
- Inherits:
-
Object
- Object
- SMG::Mapping
- Defined in:
- lib/smg/mapping/element.rb,
lib/smg/mapping.rb,
lib/smg/mapping/typecasts.rb
Overview
:nodoc:
Defined Under Namespace
Modules: TypeCasts Classes: Element
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#nested ⇒ Object
readonly
Returns the value of attribute nested.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #attach_element(tag, options) ⇒ Object
- #attach_nested(tag, options) ⇒ Object
-
#initialize ⇒ Mapping
constructor
A new instance of Mapping.
- #use_root(path) ⇒ Object
Constructor Details
#initialize ⇒ Mapping
Returns a new instance of Mapping.
7 8 9 10 11 |
# File 'lib/smg/mapping.rb', line 7 def initialize @elements = {} @nested = {} @attributes = {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/smg/mapping.rb', line 4 def attributes @attributes end |
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
4 5 6 |
# File 'lib/smg/mapping.rb', line 4 def elements @elements end |
#nested ⇒ Object (readonly)
Returns the value of attribute nested.
4 5 6 |
# File 'lib/smg/mapping.rb', line 4 def nested @nested end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
5 6 7 |
# File 'lib/smg/mapping.rb', line 5 def root @root end |
Instance Method Details
#attach_element(tag, options) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/smg/mapping.rb', line 13 def attach_element(tag,) chain = handle_path(tag) thing = Element.new(chain, ) if .key?(:at) @attributes[chain] ||= {} #@attributes[chain][thing.at] = thing @attributes[chain][thing.at] ||= [] @attributes[chain][thing.at] << thing else @elements[chain] = thing end thing end |
#attach_nested(tag, options) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/smg/mapping.rb', line 27 def attach_nested(tag,) chain = handle_path(tag) thing = Element.new(chain, .merge(:nested => true)) @nested[chain] = thing thing end |
#use_root(path) ⇒ Object
34 35 36 |
# File 'lib/smg/mapping.rb', line 34 def use_root(path) @root = normalize_path(path) end |