Sha256: 5ac1ff6a93d33d30b034125b0e853a4fa829a8251444fa28491e28bd34f6f130
Contents?: true
Size: 915 Bytes
Versions: 1
Compression:
Stored size: 915 Bytes
Contents
module JSONAPIonify::Api class SortField delegate :to_s, :inspect, to: :to_hash attr_reader :name, :order def initialize(name) @str = name.to_s if name.to_s.start_with? '-' @name = name.to_s[1..-1].to_sym @order = :desc else @name = name.to_sym @order = :asc end freeze end def ==(other) other.class == self.class && other.name == self.name end def ===(other) other.class == self.class && other.name == self.name end def id? name == :id end def contains_operator case @order when :asc :>= when :desc :<= end end def outside_operator case @order when :asc :> when :desc :< end end def to_s @str end def to_hash { name => order } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jsonapionify-0.9.0 | lib/jsonapionify/api/sort_field.rb |