Method: DataMapper::Query::Conditions::Operation.new

Defined in:
lib/dm-core/query/conditions/operation.rb

.new(slug, *operands) ⇒ AbstractOperation

Factory method to initialize an operation

Examples:

operation = Operation.new(:and, comparison)

Parameters:

  • the identifier for the operation class

  • the operands to initialize the operation with

Returns:

  • the operation matching the slug

API:

  • semipublic



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