Module: Prequel::SymbolExtensions

Defined in:
lib/prequel/core_extensions.rb

Instance Method Summary collapse

Instance Method Details

#as(alias_name) ⇒ Object



12
13
14
# File 'lib/prequel/core_extensions.rb', line 12

def as(alias_name)
  "#{self}___#{alias_name}".to_sym
end

#countObject



20
21
22
# File 'lib/prequel/core_extensions.rb', line 20

def count
  Expressions::SetFunction.new(self, :count)
end

#eq(other) ⇒ Object



16
17
18
# File 'lib/prequel/core_extensions.rb', line 16

def eq(other)
  Expressions::Equal.new(self, other)
end

#resolve_in_relations(relations) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/prequel/core_extensions.rb', line 24

def resolve_in_relations(relations)
  if self =~ /^(.+)___(.+)$/
    column_name = $1.to_sym
    alias_name = $2.to_sym
    Expressions::AliasedExpression.new(column_name, alias_name).resolve_in_relations(relations)
  else
    relations.each do |relation|
      if column = relation.get_column(self)
        return column
      end
    end
    nil
  end
end

#to_sqlObject



39
40
41
# File 'lib/prequel/core_extensions.rb', line 39

def to_sql
  inspect
end