Class: ActiveRecord::Refined::AST::Extract
- Includes:
- Arithmetics, Predications
- Defined in:
- lib/active_record/refined/ast.rb
Overview
EXTRACT(field FROM expr). The field is grammar rather than a value -- a keyword the adapter reads bare -- so it has to be a plain name, which Arel upcases on the way out.
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#operand ⇒ Object
readonly
Returns the value of attribute operand.
Instance Method Summary collapse
-
#initialize(field, operand) ⇒ Extract
constructor
A new instance of Extract.
- #to_arel(table, model) ⇒ Object
Methods included from Arithmetics
#&, #*, #+, #-, #/, #<<, #>>, #^, #|, #~
Methods included from Predications
#!=, #!~, #<, #<=, #==, #=~, #>, #>=, #between?, #bury, #casecmp?, #contains?, #dig, #dig_json, #distinct_from?, #end_with?, #false?, #ilike?, #in?, #include?, #intersect?, #key?, #like?, #member?, #not_between?, #not_distinct_from?, #not_false?, #not_ilike?, #not_in?, #not_like?, #not_null?, #not_true?, #null?, #start_with?, #subset?, #superset?, #true?, #when
Methods inherited from Node
Constructor Details
#initialize(field, operand) ⇒ Extract
Returns a new instance of Extract.
1069 1070 1071 1072 |
# File 'lib/active_record/refined/ast.rb', line 1069 def initialize(field, operand) @field = AST.check_name(field, ALIAS_NAME, "extract field") @operand = operand end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
1067 1068 1069 |
# File 'lib/active_record/refined/ast.rb', line 1067 def field @field end |
#operand ⇒ Object (readonly)
Returns the value of attribute operand.
1067 1068 1069 |
# File 'lib/active_record/refined/ast.rb', line 1067 def operand @operand end |
Instance Method Details
#to_arel(table, model) ⇒ Object
1074 1075 1076 |
# File 'lib/active_record/refined/ast.rb', line 1074 def to_arel(table, model) Arel::Nodes::Extract.new(to_arel_argument(operand, table, model), field.to_s) end |