Sha256: 5027a717e92df703487d7880609f3ae1929a831be4e36b5734fd6897b3c0f7e2

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

module Cts
  module Mpx
    module Driver
      # <Description>
      # @attribute entries
      #   @return [Array] array of deserialized entries
      # @attribute xmlns
      #   @return [Hash] active namespace received for this page
      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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cts-mpx-1.2.0 lib/cts/mpx/driver/page.rb
cts-mpx-1.1.2 lib/cts/mpx/driver/page.rb
cts-mpx-1.1.1 lib/cts/mpx/driver/page.rb
cts-mpx-1.1.0 lib/cts/mpx/driver/page.rb