Class: Cts::Mpx::Driver::Page
- Inherits:
-
Object
- Object
- Cts::Mpx::Driver::Page
- Includes:
- Creatable, Enumerable
- Defined in:
- lib/cts/mpx/driver/page.rb
Overview
<Description>
Instance Attribute Summary collapse
-
#entries ⇒ Array
Array of deserialized entries.
-
#xmlns ⇒ Hash
Active namespace received for this page.
Instance Method Summary collapse
-
#initialize ⇒ Page
constructor
A new instance of Page.
- #to_mpx_entries ⇒ Object
-
#to_s(indent_depth = nil) ⇒ String
return a json copy of the object, useful for later interpreation.
Constructor Details
#initialize ⇒ Page
Returns a new instance of Page.
16 17 18 19 |
# File 'lib/cts/mpx/driver/page.rb', line 16 def initialize @entries = [] @xmlns = {} end |
Instance Attribute Details
#entries ⇒ Array
Returns array of deserialized entries.
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 43 44 45 46 |
# File 'lib/cts/mpx/driver/page.rb', line 9 class Page include Creatable include Enumerable attribute name: 'entries', kind_of: Array attribute name: 'xmlns', kind_of: Hash def initialize @entries = [] @xmlns = {} end def to_mpx_entries c = @entries.map do |e| new_entry = Entry.create(fields: Fields.create_from_data(data: e, xmlns: xmlns)) new_entry.id = new_entry.fields['id'] new_entry end e = Entries.create collection: c e end # return a json copy of the object, useful for later interpreation # @param [Object] indent_depth sets indent depth to 2 if not nil # @return [String] json serialized copy of the page def to_s(indent_depth = nil) indent_depth = 2 if indent_depth Oj.dump( { "$xmlns" => xmlns, "entries" => entries }, indent: indent_depth ) end end |
#xmlns ⇒ Hash
Returns active namespace received for this page.
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 43 44 45 46 |
# File 'lib/cts/mpx/driver/page.rb', line 9 class Page include Creatable include Enumerable attribute name: 'entries', kind_of: Array attribute name: 'xmlns', kind_of: Hash def initialize @entries = [] @xmlns = {} end def to_mpx_entries c = @entries.map do |e| new_entry = Entry.create(fields: Fields.create_from_data(data: e, xmlns: xmlns)) new_entry.id = new_entry.fields['id'] new_entry end e = Entries.create collection: c e end # return a json copy of the object, useful for later interpreation # @param [Object] indent_depth sets indent depth to 2 if not nil # @return [String] json serialized copy of the page def to_s(indent_depth = nil) indent_depth = 2 if indent_depth Oj.dump( { "$xmlns" => xmlns, "entries" => entries }, indent: indent_depth ) end end |
Instance Method Details
#to_mpx_entries ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cts/mpx/driver/page.rb', line 21 def to_mpx_entries c = @entries.map do |e| new_entry = Entry.create(fields: Fields.create_from_data(data: e, xmlns: xmlns)) new_entry.id = new_entry.fields['id'] new_entry end e = Entries.create collection: c e end |
#to_s(indent_depth = nil) ⇒ String
return a json copy of the object, useful for later interpreation
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cts/mpx/driver/page.rb', line 35 def to_s(indent_depth = nil) indent_depth = 2 if indent_depth Oj.dump( { "$xmlns" => xmlns, "entries" => entries }, indent: indent_depth ) end |