5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/penknife/active_record/column_reader.rb', line 5
def column_reader(column_name, options = {})
name = options.delete(:as) || column_name.to_s.pluralize
column = columns_hash[column_name.to_s]
type_cast_code = column.type_cast_code('v')
line = __LINE__
self.class_eval %{
def self.#{name}
query = scoped.select(arel_table[:#{column_name}])
connection.select_all(query.to_sql).collect do |value|
v = value.values.first
#{type_cast_code}
end
end
}, __FILE__, line + 1
end
|