Class: Arel::Nodes::Case
- Inherits:
-
NodeExpression
- Object
- Node
- NodeExpression
- Arel::Nodes::Case
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/arel/nodes/case.rb
Instance Attribute Summary collapse
-
#case ⇒ Object
Returns the value of attribute case.
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#default ⇒ Object
Returns the value of attribute default.
Instance Method Summary collapse
- #else(expression) ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(expression = nil, default = nil) ⇒ Case
constructor
A new instance of Case.
- #initialize_copy(other) ⇒ Object
- #then(expression) ⇒ Object
- #when(condition, expression = nil) ⇒ Object
Methods included from Math
#&, #*, #+, #-, #/, #<<, #>>, #^, #|, #~@
Methods included from OrderPredications
Methods included from AliasPredication
Methods included from Predications
#between, #concat, #contains, #does_not_match, #does_not_match_all, #does_not_match_any, #does_not_match_regexp, #eq, #eq_all, #eq_any, #gt, #gt_all, #gt_any, #gteq, #gteq_all, #gteq_any, #in, #in_all, #in_any, #is_distinct_from, #is_not_distinct_from, #lt, #lt_all, #lt_any, #lteq, #lteq_all, #lteq_any, #matches, #matches_all, #matches_any, #matches_regexp, #not_between, #not_eq, #not_eq_all, #not_eq_any, #not_in, #not_in_all, #not_in_any, #overlaps, #quoted_array
Methods included from Expressions
#average, #count, #extract, #maximum, #minimum, #sum
Methods inherited from Node
#and, #equality?, #fetch_attribute, #invert, #not, #or, #to_sql
Methods included from FactoryMethods
#coalesce, #create_and, #create_false, #create_join, #create_on, #create_string_join, #create_table_alias, #create_true, #grouping, #lower
Constructor Details
#initialize(expression = nil, default = nil) ⇒ Case
Returns a new instance of Case.
8 9 10 11 12 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/arel/nodes/case.rb', line 8 def initialize(expression = nil, default = nil) @case = expression @conditions = [] @default = default end |
Instance Attribute Details
#case ⇒ Object
Returns the value of attribute case.
6 7 8 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/arel/nodes/case.rb', line 6 def case @case end |
#conditions ⇒ Object
Returns the value of attribute conditions.
6 7 8 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/arel/nodes/case.rb', line 6 def conditions @conditions end |
#default ⇒ Object
Returns the value of attribute default.
6 7 8 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/arel/nodes/case.rb', line 6 def default @default end |
Instance Method Details
#else(expression) ⇒ Object
24 25 26 27 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/arel/nodes/case.rb', line 24 def else(expression) @default = Else.new Nodes.build_quoted(expression) self end |
#eql?(other) ⇒ Boolean Also known as: ==
40 41 42 43 44 45 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/arel/nodes/case.rb', line 40 def eql?(other) self.class == other.class && self.case == other.case && self.conditions == other.conditions && self.default == other.default end |
#hash ⇒ Object
36 37 38 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/arel/nodes/case.rb', line 36 def hash [@case, @conditions, @default].hash end |
#initialize_copy(other) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/arel/nodes/case.rb', line 29 def initialize_copy(other) super @case = @case.clone if @case @conditions = @conditions.map { |x| x.clone } @default = @default.clone if @default end |
#then(expression) ⇒ Object
19 20 21 22 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/arel/nodes/case.rb', line 19 def then(expression) @conditions.last.right = Nodes.build_quoted(expression) self end |
#when(condition, expression = nil) ⇒ Object
14 15 16 17 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/arel/nodes/case.rb', line 14 def when(condition, expression = nil) @conditions << When.new(Nodes.build_quoted(condition), expression) self end |