Class: YeSQL::Statement

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
ActiveRecord::ConnectionAdapters::Quoting, Common::Adapter, Utils::Read
Defined in:
lib/yesql/statement.rb

Instance Method Summary collapse

Methods included from Utils::Read

#statement

Methods included from Common::Adapter

#adapter, #mysql?, #pg?

Constructor Details

#initialize(bindings = {}, file_path) ⇒ Statement

Returns a new instance of Statement.



20
21
22
23
# File 'lib/yesql/statement.rb', line 20

def initialize(bindings = {}, file_path)
  @bindings = bindings
  @file_path = file_path
end

Instance Method Details

#boundObject



25
26
27
28
29
# 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_sObject



31
32
33
# File 'lib/yesql/statement.rb', line 31

def to_s
  @to_s ||= statement(readable: true)
end

#view?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/yesql/statement.rb', line 35

def view?
  to_s =~ /^create\s.*view\s/i
end