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.
607 608 609 610 |
# File 'lib/active_record/refined/ast.rb', line 607 def initialize(kase, condition) @kase = kase @condition = condition end |
Instance Method Details
#then(value = nil, &block) ⇒ Object
612 613 614 615 616 |
# File 'lib/active_record/refined/ast.rb', line 612 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
618 619 620 |
# File 'lib/active_record/refined/ast.rb', line 618 def to_arel(_table, _model) raise ArgumentError, "when needs a matching then" end |