Class: EimXML::OpenDSL
- Inherits:
-
Object
- Object
- EimXML::OpenDSL
- Defined in:
- lib/eim_xml/dsl.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #add(content) ⇒ Object (also: #<<)
- #container ⇒ Object
-
#initialize {|_self| ... } ⇒ OpenDSL
constructor
A new instance of OpenDSL.
Constructor Details
#initialize {|_self| ... } ⇒ OpenDSL
Returns a new instance of OpenDSL.
96 97 98 99 |
# File 'lib/eim_xml/dsl.rb', line 96 def initialize @_container = nil yield(self) if block_given? end |
Class Method Details
.register ⇒ Object
92 93 94 |
# File 'lib/eim_xml/dsl.rb', line 92 def self.register(*) register_base(self, binding, *) end |
.register_base(_dsl, binding, *args) ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/eim_xml/dsl.rb', line 81 def self.register_base(_dsl, binding, *args) args.each do |klass, name| name ||= klass.name.downcase[/(?:.*::)?(.*)$/, 1] # rubocop:disable Security/Eval, Layout/LineLength eval("def #{name}(*a, &p);_build(#{klass}, *a, &p);end", binding, __FILE__, __LINE__) # def element(*a, &p);_build(Element, *a, &p);end eval("def self.#{name}(*a, &p);self.new.#{name}(*a, &p);end", binding, __FILE__, __LINE__) # def self.element(*a, &p);self.new.element(*a, &p);end # rubocop:enable Security/Eval, Layout/LineLength end end |
Instance Method Details
#add(content) ⇒ Object Also known as: <<
101 102 103 |
# File 'lib/eim_xml/dsl.rb', line 101 def add(content) @_container.add(content) end |
#container ⇒ Object
106 107 108 |
# File 'lib/eim_xml/dsl.rb', line 106 def container @_container end |