Class: DataMapper::Query::Conditions::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/dm-core/query/conditions/operation.rb

Class Method Summary collapse

Class Method Details

.new(slug, *operands) ⇒ AbstractOperation

Factory method to initialize an operation

Examples:

operation = Operation.new(:and, comparison)

Parameters:

  • slug (Symbol)

    the identifier for the operation class

  • *operands (Array)

    the operands to initialize the operation with

Returns:



19
20
21
22
23
24
25
# File 'lib/dm-core/query/conditions/operation.rb', line 19

def self.new(slug, *operands)
  if klass = operation_class(slug)
    klass.new(*operands)
  else
    raise ArgumentError, "No Operation class for #{slug.inspect} has been defined"
  end
end

.slugsArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return an Array of all the slugs for the operation classes

Returns:

  • (Array)

    the slugs of all the operation classes



33
34
35
# File 'lib/dm-core/query/conditions/operation.rb', line 33

def self.slugs
  AbstractOperation.descendants.map { |operation_class| operation_class.slug }
end