Module: EAAL::Rowset

Defined in:
lib/eaal/rowset.rb

Defined Under Namespace

Classes: RowBase, RowsetBase

Class Method Summary collapse

Class Method Details

.new(prefix, xml) ⇒ Object

  • prefix string prefix for building the RowSet name

  • xml the xml for the RowSet



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/eaal/rowset.rb', line 37

def self.new(prefix, xml)
    name = xml['name']
    columns = xml['columns'].split(',')

    classname = prefix + 'Rowset' + name.capitalize
    rowname = classname + 'Row'

    if not Object.const_defined? classname
        klass = Object.const_set(classname, Class.new(EAAL::Rowset::RowsetBase))
    else
        klass = Object.const_get(classname)
    end
    rowset = klass.new

    if not Object.const_defined? rowname
        klass = Object.const_set(rowname, Class.new(EAAL::Rowset::RowBase))
        klass.class_eval do
            attr_accessor(*columns)
        end
    else
        klass = Object.const_get(rowname)
    end

    rowset.name = name
    rowset.columns = columns
    rowset.rowclass = klass
    xml.containers.each{ |row|
        rowset << rowset.create_row(row)
    } if xml.children && xml.containers.length > 0
    rowset
end