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(v) ⇒ Object (also: #<<)
- #container ⇒ Object
-
#initialize {|_self| ... } ⇒ OpenDSL
constructor
A new instance of OpenDSL.
Constructor Details
#initialize {|_self| ... } ⇒ OpenDSL
Returns a new instance of OpenDSL.
90 91 92 93 |
# File 'lib/eim_xml/dsl.rb', line 90 def initialize @_container = nil yield(self) if block_given? end |
Class Method Details
.register(*args) ⇒ Object
86 87 88 |
# File 'lib/eim_xml/dsl.rb', line 86 def self.register(*args) register_base(self, binding, *args) end |
.register_base(dsl, binding, *args) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/eim_xml/dsl.rb', line 78 def self.register_base(dsl, binding, *args) args.each do |klass, name| name ||= klass.name.downcase[/(?:.*\:\:)?(.*)$/, 1] eval("def #{name}(*a, &p);_build(#{klass}, *a, &p);end", binding) eval("def self.#{name}(*a, &p);self.new.#{name}(*a, &p);end", binding) end end |
Instance Method Details
#add(v) ⇒ Object Also known as: <<
95 96 97 |
# File 'lib/eim_xml/dsl.rb', line 95 def add(v) @_container.add(v) end |
#container ⇒ Object
100 |
# File 'lib/eim_xml/dsl.rb', line 100 def container; @_container; end |