Sha256: a37b57984a452f979e2eb322503a569b4556395b5edba1708dde93fe32ee65bd

Contents?: true

Size: 684 Bytes

Versions: 1

Compression:

Stored size: 684 Bytes

Contents

require 'virtus'
module Ixtlan
  module DataMapper
    class Collection
      # TODO no mass-assignments, etc
      include Virtus.model( :coerce => false )

      attribute :offset, Integer
      attribute :total_count, Integer

      def initialize( data, offset = nil, count = nil )
        super()
        self.total_count = data.count
        self.offset = offset.to_i
        last = ( count ? count.to_i : self.total_count ) - 1 + self.offset
        self.data = data[ self.offset..last ]
      end

      def data=( d )
        raise "not implemented"
      end

      def to_s
        "#{self.class}[ offset=#{offset} total_count=#{total_count} ]"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ixtlan-datamapper-0.1.0 lib/ixtlan/datamapper/collection.rb~