Class: SAXMachine::SAXConfig::CollectionConfig
- Inherits:
-
Object
- Object
- SAXMachine::SAXConfig::CollectionConfig
- Defined in:
- lib/sax-machine/sax_collection_config.rb
Instance Attribute Summary collapse
-
#default_xmlns ⇒ Object
readonly
Returns the value of attribute default_xmlns.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #accessor ⇒ Object
- #handler(nsstack) ⇒ Object
-
#initialize(name, options) ⇒ CollectionConfig
constructor
A new instance of CollectionConfig.
- #xmlns_match?(ns) ⇒ Boolean
Constructor Details
#initialize(name, options) ⇒ CollectionConfig
Returns a new instance of CollectionConfig.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sax-machine/sax_collection_config.rb', line 8 def initialize(name, ) @name = name.to_s @class = [:class] @as = [:as].to_s @xmlns = case [:xmlns] when Array then [:xmlns] when String then [[:xmlns]] else nil end @default_xmlns = [:default_xmlns] if @default_xmlns && @xmlns && !@xmlns.include?(EMPTY_STRING) @xmlns << EMPTY_STRING end @record_events = [:events] end |
Instance Attribute Details
#default_xmlns ⇒ Object (readonly)
Returns the value of attribute default_xmlns.
6 7 8 |
# File 'lib/sax-machine/sax_collection_config.rb', line 6 def default_xmlns @default_xmlns end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/sax-machine/sax_collection_config.rb', line 5 def name @name end |
Instance Method Details
#accessor ⇒ Object
36 37 38 |
# File 'lib/sax-machine/sax_collection_config.rb', line 36 def accessor as end |
#handler(nsstack) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sax-machine/sax_collection_config.rb', line 24 def handler(nsstack) if @default_xmlns && (nsstack.nil? || nsstack[EMPTY_STRING] == EMPTY_STRING) nsstack = NSStack.new(nsstack, nsstack) nsstack[EMPTY_STRING] = @default_xmlns end unless @record_events SAXHandler.new(@class.new, nsstack) else SAXEventRecorder.new(nsstack) end end |
#xmlns_match?(ns) ⇒ Boolean
40 41 42 |
# File 'lib/sax-machine/sax_collection_config.rb', line 40 def xmlns_match?(ns) @xmlns.nil? || @xmlns.include?(ns) end |