Class: FluentQuery::Queries::SQL

Inherits:
FluentQuery::Query
  • Object
show all
Defined in:
lib/fluent-query/queries/sql.rb

Overview

Represents SQL query. It ensures calls occupied by Ruby. (For example ‘select()’.)

Constant Summary collapse

NONALPHA_REPLACER =
/[^a-zA-Z0-9]/

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object

 Catches missing methods calls. Converts them to tokens. In token names starting with ‘_’ skips non-alfanumeric characters.



21
22
23
24
25
26
27
28
29
30
# File 'lib/fluent-query/queries/sql.rb', line 21

def method_missing(sym, *args, &block)
    # If name starts with underscore, strips non-alfa numeric characters out
    sym = sym.to_s
    
    if sym[0].ord == 95  # "_"
        sym.gsub!(self.class::NONALPHA_REPLACER, "")
    end
    
    return super(sym.to_sym, *args, &block)
end

Instance Method Details

#processorObject

Ensures processor call of parent classes which isn’t  handled well from unknown reason via extending and falls to method_missing(…).



38
39
40
# File 'lib/fluent-query/queries/sql.rb', line 38

def processor
    super
end

#select(*args) ⇒ Object

Ensures ‘select()’ call occupied by Ruby.



46
47
48
49
# File 'lib/fluent-query/queries/sql.rb', line 46

def select(*args)
    self.push_token(:select, args)
    return self
end