lib/sax-machine/sax_config.rb in superfeedr-sax-machine-0.0.22.2 vs lib/sax-machine/sax_config.rb in superfeedr-sax-machine-0.0.23
- old
+ new
@@ -19,32 +19,36 @@
@collection_elements[name.to_s] ||= []
@collection_elements[name.to_s] << CollectionConfig.new(name, options)
end
def collection_config(name, nsstack)
- prefix, name = name.split(':', 2)
+ prefix, name = name.split(COLON, 2)
prefix, name = nil, prefix unless name # No prefix
namespace = nsstack[prefix]
- (@collection_elements[name.to_s] || []).detect { |ce|
+ return nil unless (a = @collection_elements[name.to_s])
+ a.detect { |ce|
ce.name.to_s == name.to_s &&
ce.xmlns_match?(namespace)
}
end
def element_configs_for_attribute(name, attrs)
- name = name.split(':', 2).last
- (@top_level_elements[name.to_s] || []).select do |element_config|
+ name = name.split(COLON, 2).last
+
+ return [] unless (a = @top_level_elements[name.to_s])
+ a.select do |element_config|
element_config.has_value_and_attrs_match?(attrs)
end
end
def element_config_for_tag(name, attrs, nsstack)
- prefix, name = name.split(':', 2)
+ prefix, name = name.split(COLON, 2)
prefix, name = nil, prefix unless name # No prefix
namespace = nsstack[prefix]
- (@top_level_elements[name.to_s] || []).detect do |element_config|
+ return nil unless (a = @top_level_elements[name.to_s])
+ a.detect do |element_config|
element_config.xmlns_match?(namespace) &&
element_config.attrs_match?(attrs)
end
end