Methods
- each_schema_child
- og_allocate
- schema_inheritance?
- schema_inheritance_child?
- schema_inheritance_root?
- schema_options
- table_class
Public Instance methods
[ show source ]
# File lib/og/sti.rb, line 45
45: def each_schema_child
46: return unless schema_inheritance_root?
47: self.descendents.each do |child|
48: yield child
49: end
50: end
[ show source ]
# File lib/og/sti.rb, line 27
27: def og_allocate(res, row=0)
28: begin
29: Object.constant(res["ogtype"]).allocate
30: rescue TypeError => e
31: # FIXME: use res['ogtype'] here, this is slow!
32: # But res['ogtype'] isn't implemented in -pr and some mysql exts,
33: # create compat layer
34: ogmanager.with_store do |s|
35: col = create_field_map(self)[:ogtype]
36: end
37:
38: Object.constant(res[col]).allocate
39: ensure
40: res.close if res.respond_to?(:close)
41: ogmanager.put_store
42: end
43: end
[ show source ]
# File lib/og/sti.rb, line 61
61: def schema_inheritance?
62: true
63: end
[ show source ]
# File lib/og/sti.rb, line 65
65: def schema_inheritance_child?
66: superclass.respond_to?(:schema_inheritance?)
67: end
[ show source ]
# File lib/og/sti.rb, line 69
69: def schema_inheritance_root?
70: (!superclass.respond_to?(:schema_inheritance?))
71: end
[ show source ]
# File lib/og/sti.rb, line 53
53: def schema_options
54: if schema_inheritance_child?
55: {:type => self}
56: else
57: {}
58: end
59: end
[ show source ]
# File lib/og/sti.rb, line 19
19: def table_class
20: klass = self
21: until !Og.manager.manageable?(klass) or klass.schema_inheritance_root?
22: klass = klass.superclass
23: end
24: return klass
25: end