Module: XMLMapping::ClassMethods

Defined in:
lib/xmlmapping.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



111
112
113
# File 'lib/xmlmapping.rb', line 111

def attributes
  @attributes
end

#default_namespaceObject (readonly)

Returns the value of attribute default_namespace.



114
115
116
# File 'lib/xmlmapping.rb', line 114

def default_namespace
  @default_namespace
end

#elementsObject (readonly)

Returns the value of attribute elements.



112
113
114
# File 'lib/xmlmapping.rb', line 112

def elements
  @elements
end

#text_attributeObject (readonly)

Returns the value of attribute text_attribute.



113
114
115
# File 'lib/xmlmapping.rb', line 113

def text_attribute
  @text_attribute
end

Instance Method Details

#has_attribute(attribute, options = {}) ⇒ Object



146
147
148
149
# File 'lib/xmlmapping.rb', line 146

def has_attribute(attribute, options = {})
	attr attribute
	@attributes[attribute] = options
end

#has_many(attribute, options = {}) ⇒ Object



133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/xmlmapping.rb', line 133

def has_many(attribute, options = {})
	attr attribute
	options[:cardinality] = :many
	options[:attribute] = attribute

	name = attribute
	if options.has_key? :name
		name = options[:name].to_sym
	end

	@elements[name] = options
end

#has_one(attribute, options = {}) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/xmlmapping.rb', line 120

def has_one(attribute, options = {})
	attr attribute
	options[:cardinality] = :one
	options[:attribute] = attribute
	
	name = attribute
	if options.has_key? :name
		name = options[:name].to_sym
	end

	@elements[name] = options
end

#namespace(namespace) ⇒ Object



116
117
118
# File 'lib/xmlmapping.rb', line 116

def namespace(namespace)
	@default_namespace = namespace
end

#text(attribute, options = {}) ⇒ Object



151
152
153
154
# File 'lib/xmlmapping.rb', line 151

def text(attribute, options = {})
	attr attribute
	@text_attribute = [attribute, options]
end