Module: AcDc::Body::BodyClassMethods
- Included in:
- AcDc::Body
- Defined in:
- lib/acdc/body.rb
Instance Method Summary collapse
- #attribute(name, type, options = {}) ⇒ Object
- #attributes ⇒ Object
- #element(name, type, options = {}) ⇒ Object
- #elements ⇒ Object
- #namespace(namespace = nil) ⇒ Object
- #tag_name(name = nil) ⇒ Object
Instance Method Details
#attribute(name, type, options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/acdc/body.rb', line 27 def attribute(name, type, ={}) attribute = Attribute.new(name,type,) @attributes ||= [] @attributes << attribute unless @inheritance_chain.nil? @inheritance_chain.each { |child| child.attributes << attribute } end attr_accessor attribute.method_name.intern end |
#attributes ⇒ Object
19 20 21 |
# File 'lib/acdc/body.rb', line 19 def attributes @attributes || [] end |
#element(name, type, options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/acdc/body.rb', line 37 def element(name, type, ={}) element = Element.new(name,type,) @elements ||= [] @elements << element unless @inheritance_chain.nil? @inheritance_chain.each { |child| child.elements << element } end attr_accessor element.method_name.intern end |
#elements ⇒ Object
23 24 25 |
# File 'lib/acdc/body.rb', line 23 def elements @elements || [] end |
#namespace(namespace = nil) ⇒ Object
52 53 54 55 |
# File 'lib/acdc/body.rb', line 52 def namespace(namespace = nil) @namespace = namespace if namespace @namespace end |
#tag_name(name = nil) ⇒ Object
47 48 49 50 |
# File 'lib/acdc/body.rb', line 47 def tag_name(name = nil) @tag_name = name.to_s if name @tag_name ||= to_s.split('::')[-1].downcase end |