Class: Rfm::Result::ResultSet
- Inherits:
-
Array
- Object
- Array
- Rfm::Result::ResultSet
- Defined in:
- lib/rfm_result.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#portals ⇒ Object
readonly
Returns the value of attribute portals.
Instance Method Summary collapse
-
#initialize(fmresultset, layout = nil) ⇒ ResultSet
constructor
A new instance of ResultSet.
Constructor Details
#initialize(fmresultset, layout = nil) ⇒ ResultSet
Returns a new instance of ResultSet.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rfm_result.rb', line 6 def initialize(fmresultset, layout = nil) @resultset = nil @layout = layout @fields = {} @portals = {} doc = REXML::Document.new(fmresultset) root = doc.root # check for errors error = root.elements['error'].attributes['code'].to_i raise "Error #{error} occurred while processing the request" if error != 0 && error != 401 # process field metadata root.elements['metadata'].each_element('field-definition') { |field| name = field.attributes['name'] @fields[name] = Field.new(field) } @fields.freeze # process relatedset metadata root.elements['metadata'].each_element('relatedset-definition') { || table = .attributes['table'] fields = {} .each_element('field-definition') { |field| name = field.attributes['name'].sub(Regexp.new(table + '::'), '') fields[name] = Field.new(field) } @portals[table] = fields } @portals.freeze # build rows root.elements['resultset'].each_element('record') { |record| self << Record.new(record, self, @fields, @layout) } end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
44 45 46 |
# File 'lib/rfm_result.rb', line 44 def fields @fields end |
#portals ⇒ Object (readonly)
Returns the value of attribute portals.
44 45 46 |
# File 'lib/rfm_result.rb', line 44 def portals @portals end |