Sha256: 3cc69b297232aa6d327ea7d4574bb8cf2d42606f337a45b5c2b868157bb877d3

Contents?: true

Size: 805 Bytes

Versions: 11

Compression:

Stored size: 805 Bytes

Contents

# TODO: rename this DM::Symbol::Direction

# TODO: add a method to convert it into a DM::Query::Sort object, eg:
#   operator.sort_for(model)

# TODO: rename #target to #property_name

# TODO: make sure Query converts this into a DM::Query::Sort object
#   immediately and passes that down to the Adapter

# TODO: remove #get method

module DataMapper
  class Query
    class Direction < Operator

      # @api private
      def reverse!
        @operator = @operator == :asc ? :desc : :asc
        self
      end

      # @api private
      def get(resource)
        Sort.new(target.get(resource), @operator == :asc)
      end

      private

      # @api private
      def initialize(target, operator = :asc)
        super
      end
    end # class Direction
  end # class Query
end # module DataMapper

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
ardm-core-1.3.0 lib/dm-core/query/direction.rb
ardm-core-1.2.1 lib/dm-core/query/direction.rb
dm-core-1.2.1 lib/dm-core/query/direction.rb
ghost_dm-core-1.3.0.beta lib/dm-core/query/direction.rb
dm-core-1.2.0 lib/dm-core/query/direction.rb
dm-core-1.2.0.rc2 lib/dm-core/query/direction.rb
dm-core-1.2.0.rc1 lib/dm-core/query/direction.rb
dm-core-1.1.0 lib/dm-core/query/direction.rb
dm-core-1.1.0.rc3 lib/dm-core/query/direction.rb
dm-core-1.1.0.rc2 lib/dm-core/query/direction.rb
dm-core-1.1.0.rc1 lib/dm-core/query/direction.rb