Class: Rfm::Metadata::Datum

Inherits:
Object show all
Defined in:
lib/rfm/metadata/datum.rb

Overview

< DelegateClass(Field)

Instance Method Summary collapse

Instance Method Details

#field_element_close_callback(cursor) ⇒ Object

Should return value only.


34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rfm/metadata/datum.rb', line 34

def field_element_close_callback(cursor)
	record = cursor.parent.object
	resultset = cursor.top.object

	name = get_mapped_name(@attributes['name'].to_s, resultset)
	field = resultset.field_meta[name]
	data = @attributes['data'] #'data'
	#puts ["\nDATUM", name, record.class, resultset.class, data]
	#puts ["\nDATUM", self.to_yaml]
	record[name] = field.coerce(data)
end

#get_mapped_name(name, resultset) ⇒ Object


7
8
9
10
# File 'lib/rfm/metadata/datum.rb', line 7

def get_mapped_name(name, resultset)
	#puts ["\nDATUM#get_mapped_name", "name: #{name}", "mapping: #{resultset.layout.field_mapping.to_yaml}"]
	(resultset && resultset.layout && resultset.layout.field_mapping[name]) || name
end

#main_callback(cursor) ⇒ Object

NOT sure what this method is for. Can't find a reference to it.


13
14
15
16
17
18
19
# File 'lib/rfm/metadata/datum.rb', line 13

def main_callback(cursor)
	resultset = cursor.top.object
	name = get_mapped_name(@attributes['name'].to_s, resultset)
	field = resultset.field_meta[name]
	data = @attributes['data']
	cursor.parent.object[name.downcase] = field.coerce(data)
end

#portal_field_element_close_callback(cursor) ⇒ Object


21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rfm/metadata/datum.rb', line 21

def portal_field_element_close_callback(cursor)
	resultset = cursor.top.object
	table, name = @attributes['name'].to_s.split('::')
	#puts ['DATUM_portal_callback_01', table, name].join(', ')
	name = get_mapped_name(name, resultset)
	field = resultset.portal_meta[table.downcase][name.downcase]
	data = @attributes['data']
	#puts ['DATUM_portal_callback_02', resultset.class, table, name, field, data].join(', ')
	#(puts resultset.portal_meta.to_yaml) unless field
	cursor.parent.object[name.downcase] = field.coerce(data)
end