Method: NativeQuery::Join#fields

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

#fields(*args) ⇒ Object

Sets hash for select from joined table. Without arguments returns fields list.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/native-query/join.rb', line 88

def fields(*args)
    if args.empty?
        result = { }
        @fields.each do |i|
            if not i.kind_of? Hash
                i = {i => i}
            end
            
            i.each_pair do |from, to|
                result[__fix_field(from)] = @table.to_s << "_" << to.to_s
            end
        end
        
        return result
    else
        @fields += args
        return self
    end
end