Class: MetaWhere::Function
- Inherits:
-
Object
- Object
- MetaWhere::Function
- Defined in:
- lib/meta_where/function.rb
Instance Attribute Summary collapse
-
#alias ⇒ Object
Returns the value of attribute alias.
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#table ⇒ Object
Returns the value of attribute table.
Instance Method Summary collapse
- #+(value) ⇒ Object
- #-(value) ⇒ Object
- #<(value) ⇒ Object
- #<=(value) ⇒ Object
- #=~(value) ⇒ Object
- #>(value) ⇒ Object
- #>=(value) ⇒ Object
- #>>(value) ⇒ Object
- #^(value) ⇒ Object
- #as(val) ⇒ Object
-
#initialize(name, *args) ⇒ Function
constructor
A new instance of Function.
- #to_sqlliteral ⇒ Object (also: #to_sql)
-
#to_sym ⇒ Object
Play “nicely” with expand_hash_conditions_for_aggregates.
Constructor Details
#initialize(name, *args) ⇒ Function
Returns a new instance of Function.
6 7 8 9 |
# File 'lib/meta_where/function.rb', line 6 def initialize(name, *args) @name = name @args = args end |
Instance Attribute Details
#alias ⇒ Object
Returns the value of attribute alias.
4 5 6 |
# File 'lib/meta_where/function.rb', line 4 def alias @alias end |
#args ⇒ Object (readonly)
Returns the value of attribute args.
3 4 5 |
# File 'lib/meta_where/function.rb', line 3 def args @args end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/meta_where/function.rb', line 3 def name @name end |
#table ⇒ Object
Returns the value of attribute table.
4 5 6 |
# File 'lib/meta_where/function.rb', line 4 def table @table end |
Instance Method Details
#+(value) ⇒ Object
45 46 47 |
# File 'lib/meta_where/function.rb', line 45 def +(value) MetaWhere::Condition.new(self, value, :in) end |
#-(value) ⇒ Object
49 50 51 |
# File 'lib/meta_where/function.rb', line 49 def -(value) MetaWhere::Condition.new(self, value, :not_in) end |
#<(value) ⇒ Object
72 73 74 |
# File 'lib/meta_where/function.rb', line 72 def <(value) MetaWhere::Condition.new(self, value, :lt) end |
#<=(value) ⇒ Object
76 77 78 |
# File 'lib/meta_where/function.rb', line 76 def <=(value) MetaWhere::Condition.new(self, value, :lteq) end |
#=~(value) ⇒ Object
53 54 55 |
# File 'lib/meta_where/function.rb', line 53 def =~(value) MetaWhere::Condition.new(self, value, :matches) end |
#>(value) ⇒ Object
64 65 66 |
# File 'lib/meta_where/function.rb', line 64 def >(value) MetaWhere::Condition.new(self, value, :gt) end |
#>=(value) ⇒ Object
68 69 70 |
# File 'lib/meta_where/function.rb', line 68 def >=(value) MetaWhere::Condition.new(self, value, :gteq) end |
#>>(value) ⇒ Object
37 38 39 |
# File 'lib/meta_where/function.rb', line 37 def >>(value) MetaWhere::Condition.new(self, value, :eq) end |
#^(value) ⇒ Object
41 42 43 |
# File 'lib/meta_where/function.rb', line 41 def ^(value) MetaWhere::Condition.new(self, value, :not_eq) end |
#as(val) ⇒ Object
11 12 13 14 |
# File 'lib/meta_where/function.rb', line 11 def as(val) self.alias = val self end |
#to_sqlliteral ⇒ Object Also known as: to_sql
16 17 18 19 20 21 |
# File 'lib/meta_where/function.rb', line 16 def to_sqlliteral Arel.sql( ("#{name}(#{(['%s'] * args.size).join(',')})" % contextualize_args) + (self.alias ? " AS #{self.alias}" : '') ) end |
#to_sym ⇒ Object
Play “nicely” with expand_hash_conditions_for_aggregates
81 82 83 |
# File 'lib/meta_where/function.rb', line 81 def to_sym self end |