Sha256: c4ca63aab7e644a703645b9228f53fa39e7d0a3f66f8dc68f3fc4240ac2cf6ae
Contents?: true
Size: 881 Bytes
Versions: 2
Compression:
Stored size: 881 Bytes
Contents
class Parelation::Criteria::Order::Object # @return [Hash] the possible directions (asc, desc) # for database queries. # DIRECTIONS = { "asc" => :asc, "desc" => :desc, } # @return [String] # attr_reader :order # @param order [String] # def initialize(order) @order = order end # @return [Hash] returns criteria for {ActiveRecord::Relation}. # # @example # { created_at: :asc } # def criteria { field => direction } end private # @return [String] the name of the field to perform the ordering on. # def field parts.first || "" end # @return [Symbol, nil] the direction to order {#field}, # either :asc or :desc. # def direction DIRECTIONS[parts.last] end # @return [Array<String, nil>] the criteria chunks (separated by +:+). # def parts @parts ||= order.split(":") end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
parelation-1.0.0 | lib/parelation/criteria/order/object.rb |
parelation-0.2.0 | lib/parelation/criteria/order/object.rb |