Class: ActiveRecord::Refined::AST::Case::Pending

Inherits:
Node
  • Object
show all
Defined in:
lib/active_record/refined/ast.rb

Overview

What a when is until its then arrives. A Node so that using it as one says what is missing rather than reaching ActiveRecord as something it cannot read.

Instance Method Summary collapse

Methods inherited from Node

#as, #asc, #desc

Constructor Details

#initialize(kase, condition) ⇒ Pending

Returns a new instance of Pending.



447
448
449
450
# File 'lib/active_record/refined/ast.rb', line 447

def initialize(kase, condition)
  @kase = kase
  @condition = condition
end

Instance Method Details

#then(value = nil, &block) ⇒ Object



452
453
454
455
456
# File 'lib/active_record/refined/ast.rb', line 452

def then(value = nil, &block)
  Case.new(@kase.operand,
           @kase.whens + [[@condition, Case.argument(:then, value, block)]],
           @kase.default)
end

#to_arel(_table, _model) ⇒ Object

Raises:

  • (ArgumentError)


458
459
460
# File 'lib/active_record/refined/ast.rb', line 458

def to_arel(_table, _model)
  raise ArgumentError, "when needs a matching then"
end