Class: ActiveRecord::Refined::AST::Case::Pending
- 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 Active Record as
something it cannot read.
Instance Method Summary collapse
-
#initialize(kase, condition) ⇒ Pending
constructor
A new instance of Pending.
- #then(value = nil, &block) ⇒ Object
- #to_arel(_table, _model) ⇒ Object
Methods inherited from Node
Constructor Details
#initialize(kase, condition) ⇒ Pending
Returns a new instance of Pending.
454 455 456 457 |
# File 'lib/active_record/refined/ast.rb', line 454 def initialize(kase, condition) @kase = kase @condition = condition end |
Instance Method Details
#then(value = nil, &block) ⇒ Object
459 460 461 462 463 |
# File 'lib/active_record/refined/ast.rb', line 459 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
465 466 467 |
# File 'lib/active_record/refined/ast.rb', line 465 def to_arel(_table, _model) raise ArgumentError, "when needs a matching then" end |