last (DataMapper::Model)

    # File lib/dm-core/model.rb, line 326
        def last(*args)
          last_arg = args.last

          limit      = args.first if args.first.kind_of?(Integer)
          with_query = last_arg.respond_to?(:merge) && !last_arg.blank?

          query = with_query ? last_arg : {}

          query = if query.kind_of?(Query)
            query.slice(0, limit || 1).reverse!
          else
            offset = query.fetch(:offset, 0)
            query  = query.except(:offset)
            scoped_query(query).slice(offset, limit || 1).reverse!
          end

          if limit
            all(query)
          else
            query.repository.read(query).last
          end
        end