Class: Graffiti::SqlExpression

Inherits:
Array
  • Object
show all
Defined in:
lib/graffiti/sql_mapper.rb

Instance Method Summary collapse

Constructor Details

#initialize(*parts) ⇒ SqlExpression

Returns a new instance of SqlExpression.



49
50
51
# File 'lib/graffiti/sql_mapper.rb', line 49

def initialize(*parts)
  super parts
end

Instance Method Details

#hashObject



86
87
88
# File 'lib/graffiti/sql_mapper.rb', line 86

def hash
  self.to_s.hash
end

#rebind!(rebind, &block) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/graffiti/sql_mapper.rb', line 70

def rebind!(rebind, &block)
  self.each_with_index do |part, i|
    case part
    when SqlExpression
      part.rebind!(rebind, &block)
    when SqlNodeBinding
      if rebind[part]
        self[i] = rebind[part] 
        yield part if block_given?
      end
    end
  end
end

#to_sObject Also known as: to_str



53
54
55
# File 'lib/graffiti/sql_mapper.rb', line 53

def to_s
  '(' << self.join(' ') << ')'
end

#traverse(&block) ⇒ Object



59
60
61
62
63
64
65
66
67
68
# File 'lib/graffiti/sql_mapper.rb', line 59

def traverse(&block)
  self.each do |part|
    case part
    when SqlExpression
      part.traverse(&block)
    else
      yield
    end
  end
end