6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/active-keso.rb', line 6
def to_keso nil_fix = {}
tuples = []
self.each do |value|
if value.is_a? ActiveRecord::Base
tuple = Tuple.new
value.attribute_names.each do |column_name|
v = value[column_name]
v = nil_fix[column_name.to_sym] unless v
tuple = tuple.add(column_name.to_sym => v)
end
tuples.push tuple
else
throw "Sorry but this is only for active record =/"
end
end
return Relation.new if tuples.length == 0
to_return = Relation.new tuples.first.heading
tuples.each do |tuple|
to_return = to_return.add tuple
end
to_return
end
|