Parent

Methods

Class/Module Index [+]

Quicksearch

DataMapper::Query::Conditions::Comparison

An abstract class which provides easy access to comparison operators

@example Creating a new comparison

Comparison.new(:eql, MyClass.my_property, "value")

Public Class Methods

new(slug, subject, value) click to toggle source

Creates a new Comparison instance

The returned instance will be suitable for matching the given subject (property or relationship) against the value.

@param [Symbol] slug

The type of comparison operator required. One of: :eql, :in, :gt,
:gte, :lt, :lte, :regexp, :like.

@param [Property, Associations::Relationship]

The subject of the comparison - the value of the subject will be
matched against the given value parameter.

@param [Object] value

The value for the comparison.

@return [DataMapper::Query::Conditions::AbstractComparison]

@example

Comparison.new(:eql, MyClass.properties[:id], 1)

@api semipublic

# File lib/dm-core/query/conditions/comparison.rb, line 58
def self.new(slug, subject, value)
  if klass = comparison_class(slug)
    klass.new(subject, value)
  else
    raise ArgumentError, "No Comparison class for #{slug.inspect} has been defined"
  end
end
slugs() click to toggle source

Returns an array of all slugs registered with Comparison

@return [Array<Symbol>]

@api private

# File lib/dm-core/query/conditions/comparison.rb, line 71
def self.slugs
  AbstractComparison.descendants.map { |comparison_class| comparison_class.slug }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.