Module: XMLable::Mixins::Container
- Defined in:
- lib/xmlable/mixins/container.rb
Overview
Container module contains the logic for the XML objects groups
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#__empty? ⇒ Boolean
private
Does this container contain only empty objects?.
-
#__initialize_with(val) ⇒ Object
private
Initialize container with params.
-
#__set_handler(handler) ⇒ Object
private
Set current object handler.
-
#__set_parent_node(node) ⇒ Object
private
Parent XML node.
-
#new(args = nil) ⇒ XMLable::Mixins::Object
Create new element.
Instance Attribute Details
#__handler ⇒ XMLable::Handlers::Elements (readonly)
8 9 10 |
# File 'lib/xmlable/mixins/container.rb', line 8 def __handler @__handler end |
Instance Method Details
#__empty? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Does this container contain only empty objects?
66 67 68 |
# File 'lib/xmlable/mixins/container.rb', line 66 def __empty? all?(&:__empty?) end |
#__initialize_with(val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize container with params
55 56 57 |
# File 'lib/xmlable/mixins/container.rb', line 55 def __initialize_with(val) val.each { |v| new(v) } end |
#__set_handler(handler) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set current object handler
33 34 35 |
# File 'lib/xmlable/mixins/container.rb', line 33 def __set_handler(handler) @__handler = handler end |
#__set_parent_node(node) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Parent XML node
44 45 46 |
# File 'lib/xmlable/mixins/container.rb', line 44 def __set_parent_node(node) @__parent_node = node end |
#new(args = nil) ⇒ XMLable::Mixins::Object
Create new element
17 18 19 20 21 22 23 24 |
# File 'lib/xmlable/mixins/container.rb', line 17 def new(args = nil) xml = Nokogiri::XML::Element.new(@__handler.tag.to_s, @__parent_node) el = @__handler.from_xml_element(xml) el.__initialize_with(args) if args @__parent_node << xml self << el el end |