Class: DataMapper::Query::Conditions::AbstractComparison

Class | DataMapper::Query::Conditions::AbstractComparison
In: | lib/dm-core/query/conditions/comparison.rb
Parent: | Object

A base class for the various comparison classes.

### Methods

descendants inherited inspect new property? relationship? slug slug to_s valid?

### Attributes

expected | [R] | Holds the actual value of the given property or relationship @return [Object] @api semipublic
loaded_value | [R] | The loaded/typecast value In the case of primitive types, this will be the same as `value`, however when using custom types this stores the loaded value. If writing an adapter, you should use `value`, while plugin authors should refer to `loaded_value`. @return [Object] @api semipublic
subject | [R] | The property or relationship which is being matched against @return [Property, Associations::Relationship] @api semipublic
value | [R] | Value to be compared with the subject This value is compared against that contained in the subject when filtering collections, or the value in the repository when performing queries. In the case of custom types, this is the value as it is stored in the repository. @return [Object] @api semipublic

### Public Class methods

descendants()

Keeps track of AbstractComparison subclasses (used in Comparison)

@return [Set<AbstractComparison>] @api private

inherited(comparison_class)

Registers AbstractComparison subclasses (used in Comparison)

@api private

new(subject, value)

Creates a new AbstractComparison instance with `subject` and `value`

@param [Property, Associations::Relationship] subject

      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.

@api semipublic

slug(slug = nil)

Setter/getter: allows subclasses to easily set their slug

@param [Symbol] slug

      The slug to be set for this class. Passing nil returns the current
      value instead.

@return [Symbol]

      The current slug set for the Comparison.

@example Creating a MyComparison compairson with slug :exact.

      class MyComparison < AbstractComparison
        slug :exact
      end

@api semipublic

### Public Instance methods

inspect()

Returns a human-readable representation of this object

@return [String]

@api semipublic

property?()

Returns whether the subject is a Property

@return [Boolean]

@api semipublic

relationship?()

Returns whether the subject is a Relationship

@return [Boolean]

@api semipublic

slug()

Return the comparison class slug

@return [Symbol]

      the comparison class slug

@api private

to_s()

Returns a string version of this Comparison object

@example

      Comparison.new(:==, MyClass.my_property, "value")
      # => "my_property == value"

@return [String]

@api semipublic

valid?()

Tests that the Comparison is valid

Subclasses can overload this to customise the means by which they determine the validity of the comparison. valid? is called prior to performing a query on the repository: each Comparison within a Query must be valid otherwise the query will not be performed.

@see DataMapper::Property#valid? @see DataMapper::Associations::Relationship#valid?

@return [Boolean]

@api semipublic

[Validate]