class MSS::Core::XML::RootFrame
Public Class Methods
new(rules)
click to toggle source
Calls superclass method
MSS::Core::XML::Frame::new
# File lib/mss/core/xml/root_frame.rb, line 19 def initialize rules @inflected = {} @indexes = {} setup_indexes(rules) super(self, nil, 'XML', rules) end
Public Instance Methods
add_to_index(index_name, key, value)
click to toggle source
# File lib/mss/core/xml/root_frame.rb, line 36 def add_to_index index_name, key, value @indexes[index_name] ||= {} @indexes[index_name][key] = value end
build_child_frame(element_name)
click to toggle source
# File lib/mss/core/xml/root_frame.rb, line 26 def build_child_frame element_name Frame.new(self, self, element_name, rules) end
inflect(element_name)
click to toggle source
The root frame maintains a cache of inflected element names.
# File lib/mss/core/xml/root_frame.rb, line 42 def inflect element_name @inflected[element_name] ||= Inflection.ruby_name(element_name).to_sym end
value()
click to toggle source
# File lib/mss/core/xml/root_frame.rb, line 30 def value value = @data.values.find{|v| v.is_a?(Hash) } value ||= {} value.merge(@indexes) end
Protected Instance Methods
setup_indexes(rules)
click to toggle source
recursively crawls the parser rules and looks for elements that index values. Adds an empty index for each of these.
# File lib/mss/core/xml/root_frame.rb, line 50 def setup_indexes rules if rules[:children] rules[:children].each_pair do |child_name,child_rules| if index = child_rules[:index] @indexes[index[:name]] = {} end setup_indexes(child_rules) end end end