Class: PolyrexBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/polyrex-builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(rows = [], parents: [], summary: {}, rootname: 'items') ⇒ PolyrexBuilder

Returns a new instance of PolyrexBuilder.



12
13
14
15
16
17
18
19
20
21
# File 'lib/polyrex-builder.rb', line 12

def initialize(rows=[], parents: [], summary: {}, rootname: 'items')

  records = rows.map {|x|  pxify(x, parents) }
  
  summary.merge!({recordx_type: 'polyrex'})
  h = {rootname.to_sym => {summary: summary, records: records }}

  @a = RexleBuilder.new(h).to_a[3]

end

Instance Method Details

#to_aObject



23
24
25
# File 'lib/polyrex-builder.rb', line 23

def to_a()
  @a
end

#to_xmlObject



27
28
29
# File 'lib/polyrex-builder.rb', line 27

def to_xml()  
  Rexle.new(@a).xml pretty: true    
end