Class: MetaWhere::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/meta_where/function.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#aliasObject

Returns the value of attribute alias.



4
5
6
# File 'lib/meta_where/function.rb', line 4

def alias
  @alias
end

#argsObject (readonly)

Returns the value of attribute args.



3
4
5
# File 'lib/meta_where/function.rb', line 3

def args
  @args
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/meta_where/function.rb', line 3

def name
  @name
end

#tableObject

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_sqlliteralObject 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_symObject

Play “nicely” with expand_hash_conditions_for_aggregates



81
82
83
# File 'lib/meta_where/function.rb', line 81

def to_sym
  self
end