class YeSQL::Statement
Attributes
bindings[R]
file_path[R]
Public Class Methods
new(bindings = {}, file_path)
click to toggle source
# File lib/yesql/statement.rb, line 20 def initialize(bindings = {}, file_path) @bindings = bindings @file_path = file_path end
Public Instance Methods
bound()
click to toggle source
# File lib/yesql/statement.rb, line 25 def bound to_s.gsub(::YeSQL::BIND_REGEX) do |match| extract_bind_values(extractor[match[/(\w+)/].to_sym]) end end
to_s()
click to toggle source
# File lib/yesql/statement.rb, line 31 def to_s @to_s ||= statement(readable: true) end
view?()
click to toggle source
# File lib/yesql/statement.rb, line 35 def view? to_s =~ /^create\s.*view\s/i end
Private Instance Methods
extract_bind_values(match)
click to toggle source
# File lib/yesql/statement.rb, line 43 def extract_bind_values(match) return quote(match[:value]) if view? match[:bind][:vars] end
extractor()
click to toggle source
# File lib/yesql/statement.rb, line 49 def extractor ::YeSQL::Bindings::Extractor.new(bindings: bindings).call end