Class: Babik::QuerySet::Update::Assignment::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/babik/queryset/lib/update/assignment.rb

Overview

Represents a table field. It will be used when an update field is based on its value an nothing else. For example:

UPDATE SET stars = stars + 1

Direct Known Subclasses

Decrement, Divide, Increment, Multiply

Instance Method Summary collapse

Constructor Details

#initialize(field, operation, value) ⇒ Operation

Returns a new instance of Operation.



64
65
66
67
68
# File 'lib/babik/queryset/lib/update/assignment.rb', line 64

def initialize(field, operation, value)
  @field = field
  @operation = operation
  @value = value
end

Instance Method Details

#sql_valueString

Return the right part of the assignment of the UPDATE statement.

Returns:

  • (String)

    right part of the assignment with the format <field> <operation> <value>.



72
73
74
# File 'lib/babik/queryset/lib/update/assignment.rb', line 72

def sql_value
  "#{@field} #{@operation} #{@value}"
end