11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/ruckus/structure/relate.rb', line 11
def relate(attr, field, opts={})
opts[:through] ||= :value
raise "need a valid field to relate" if not field
raise "need :to argument" if not opts[:to]
self.initializers << lambda do
f = send(field)
case attr
when :value
f.value = opts[:through]
f.instance_eval { @from_field = opts[:to] }
when :size
f.instance_eval {
@in_size = {
:meth => opts[:through],
:from_field => opts[:to]
}
}
end
end
end
|