Module: AcDc::Body::BodyClassMethods

Included in:
AcDc::Body
Defined in:
lib/acdc/body.rb

Instance Method Summary collapse

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, options={})
  attribute = Attribute.new(name,type,options)
  @attributes ||= []
  @attributes << attribute
  unless @inheritance_chain.nil? 
    @inheritance_chain.each { |child| child.attributes << attribute }
  end
  attr_accessor attribute.method_name.intern
end

#attributesObject



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, options={})
  element = Element.new(name,type,options)
  @elements ||= []
  @elements << element
  unless @inheritance_chain.nil? 
    @inheritance_chain.each { |child| child.elements << element }
  end
  attr_accessor element.method_name.intern
end

#elementsObject



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