Method: NativeQuery::Model#method_missing

Defined in:
lib/native-query/model.rb

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

Maps missing calls to tables.

Arguments are expected to be field names, so given to field query method.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/native-query/model.rb', line 70

def method_missing(sym, *args, &block)
    
    # If it's binding to the connection
    if sym.in? Model::RELEVANT_METHODS
        return self.connection.send(sym, *args, &block)
        
    # In otherwise, it's query request
    else
        query = Query::new(self.connection, sym)
        
        if args and not args.empty?
            query.fields(*args)
        end
        
        if not block.nil?
            result = query.instance_eval(&block)
        else
            result = query
        end

        return result
    end
    
end