Class: ActiveRecord::Refined::AST::Case::When
- 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) ⇒ When
constructor
A new instance of When.
-
#then(value = nil, &block) ⇒ AST::Case
THEN value, as a value or a block, for thewhenbefore it.
Methods inherited from Node
Constructor Details
#initialize(kase, condition) ⇒ When
Returns a new instance of When.
925 926 927 928 |
# File 'lib/active_record/refined/ast.rb', line 925 def initialize(kase, condition) @kase = kase @condition = condition end |
Instance Method Details
#then(value = nil, &block) ⇒ AST::Case
THEN value, as a value or a block, for the when before it.
932 933 934 935 936 |
# File 'lib/active_record/refined/ast.rb', line 932 def then(value = nil, &block) Case.new(@kase.operand, @kase.whens + [[@condition, Case.argument(:then, value, block)]], @kase.default) end |