Class: SMG::Mapping

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeMapping

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

#attributesObject (readonly)

Returns the value of attribute attributes.



4
5
6
# File 'lib/smg/mapping.rb', line 4

def attributes
  @attributes
end

#elementsObject (readonly)

Returns the value of attribute elements.



4
5
6
# File 'lib/smg/mapping.rb', line 4

def elements
  @elements
end

#nestedObject (readonly)

Returns the value of attribute nested.



4
5
6
# File 'lib/smg/mapping.rb', line 4

def nested
  @nested
end

#rootObject (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,options)
  chain = handle_path(tag)
  thing = Element.new(chain, options)
  if options.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,options)
  chain = handle_path(tag)
  thing = Element.new(chain, options.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