Sha256: b01eabba5a39054fe8b389aa3005e13400405f5565412cc912a92a45f74ee02a

Contents?: true

Size: 656 Bytes

Versions: 5

Compression:

Stored size: 656 Bytes

Contents

class Array
  def __basetype
    :array
  end

  def to_database_view(depth, ranges = {}, params = {})
    obj = super

    if depth > 0
      obj[:elements] = {}
      obj[:elementsSize] = self.size

      range_from = ranges[:elements] ? Integer(ranges[:elements][0]) : 1
      range_to = ranges[:elements] ? Integer(ranges[:elements][1]) : 10

      if (params[:allElements])
        range_from = 1
        range_to = self.size
      end
      
      ((range_from - 1)..[range_to - 1, self.size - 1].min).each do |index|
        obj[:elements][index + 1] = self[index].to_database_view(depth - 1, {}, params)
      end
    end

    return obj
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
maglev-database-explorer-0.0.5 lib/maglev-database-explorer/database_views/array.rb
maglev-database-explorer-0.0.4 lib/maglev-database-explorer/database_views/array.rb
maglev-database-explorer-0.0.3 lib/maglev-database-explorer/database_views/array.rb
maglev-database-explorer-0.0.2 lib/maglev-database-explorer/database_views/array.rb
maglev-database-explorer-0.0.1 lib/maglev-database-explorer/database_views/array.rb