Class: SAXMachine::SAXConfig
- Inherits:
-
Object
- Object
- SAXMachine::SAXConfig
show all
- Defined in:
- lib/sax-machine/sax_config.rb,
lib/sax-machine/sax_element_config.rb,
lib/sax-machine/sax_collection_config.rb
Defined Under Namespace
Classes: CollectionConfig, ElementConfig
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of SAXConfig.
8
9
10
11
|
# File 'lib/sax-machine/sax_config.rb', line 8
def initialize
@top_level_elements = {}
@collection_elements = {}
end
|
Instance Attribute Details
#collection_elements ⇒ Object
Returns the value of attribute collection_elements.
6
7
8
|
# File 'lib/sax-machine/sax_config.rb', line 6
def collection_elements
@collection_elements
end
|
#top_level_elements ⇒ Object
Returns the value of attribute top_level_elements.
6
7
8
|
# File 'lib/sax-machine/sax_config.rb', line 6
def top_level_elements
@top_level_elements
end
|
Instance Method Details
#add_collection_element(name, options) ⇒ Object
27
28
29
30
|
# File 'lib/sax-machine/sax_config.rb', line 27
def add_collection_element(name, options)
@collection_elements[name.to_s] = [] unless @collection_elements[name.to_s]
@collection_elements[name.to_s] << CollectionConfig.new(name, options)
end
|
#add_top_level_element(name, options) ⇒ Object
22
23
24
25
|
# File 'lib/sax-machine/sax_config.rb', line 22
def add_top_level_element(name, options)
@top_level_elements[name.to_s] = [] unless @top_level_elements[name.to_s]
@top_level_elements[name.to_s] << ElementConfig.new(name, options)
end
|
#collection_config(name, attrs) ⇒ Object
32
33
34
35
|
# File 'lib/sax-machine/sax_config.rb', line 32
def collection_config(name, attrs)
ces = @collection_elements[name.to_s]
ces && ces.detect { |cc| cc.attrs_match?(attrs) }
end
|
#columns ⇒ Object
13
14
15
|
# File 'lib/sax-machine/sax_config.rb', line 13
def columns
@top_level_elements.map {|name, ecs| ecs }.flatten
end
|
#element_config_for_tag(name, attrs) ⇒ Object
42
43
44
45
|
# File 'lib/sax-machine/sax_config.rb', line 42
def element_config_for_tag(name, attrs)
tes = @top_level_elements[name.to_s]
tes && tes.detect { |ec| ec.attrs_match?(attrs) }
end
|
#element_configs_for_attribute(name, attrs) ⇒ Object
37
38
39
40
|
# File 'lib/sax-machine/sax_config.rb', line 37
def element_configs_for_attribute(name, attrs)
tes = @top_level_elements[name.to_s]
tes && tes.select { |ec| ec.has_value_and_attrs_match?(attrs) } || []
end
|
#initialize_copy(sax_config) ⇒ Object
17
18
19
20
|
# File 'lib/sax-machine/sax_config.rb', line 17
def initialize_copy(sax_config)
@top_level_elements = deep_clone_elements(sax_config.top_level_elements)
@collection_elements = deep_clone_elements(sax_config.collection_elements)
end
|