Sha256: 4cc472ef29ab4914d0cc143c8770e2905f34a6199e9a0161ff75dc9dfac54f57
Contents?: true
Size: 1.58 KB
Versions: 5
Compression:
Stored size: 1.58 KB
Contents
# encoding: UTF-8 module Plucky module Extensions module Symbol def gt SymbolOperator.new(self, 'gt') end def lt SymbolOperator.new(self, 'lt') end def gte SymbolOperator.new(self, 'gte') end def lte SymbolOperator.new(self, 'lte') end def ne SymbolOperator.new(self, 'ne') end def in SymbolOperator.new(self, 'in') end def nin SymbolOperator.new(self, 'nin') end def mod SymbolOperator.new(self, 'mod') end def all SymbolOperator.new(self, 'all') end def size SymbolOperator.new(self, 'size') end unless Symbol.instance_methods.include?(:size) # Ruby 1.9 defines symbol size def exists SymbolOperator.new(self, 'exists') end def asc SymbolOperator.new(self, 'asc') end def desc SymbolOperator.new(self, 'desc') end end end end class SymbolOperator include Comparable attr_reader :field, :operator def initialize(field, operator, options={}) @field, @operator = field, operator end unless method_defined?(:initialize) def <=>(other) if field == other.field operator <=> other.operator else field.to_s <=> other.field.to_s end end def hash field.hash + operator.hash end def eql?(other) self == other end def ==(other) other.class == self.class && field == other.field && operator == other.operator end end class Symbol include Plucky::Extensions::Symbol end
Version data entries
5 entries across 5 versions & 1 rubygems