Class: SequelRelation::RelationshipManager
- Defined in:
- lib/ramaze/contrib/sequel/relation.rb
Constant Summary collapse
- TODO =
{}
Instance Method Summary collapse
- #belongs_to(model) ⇒ Object
- #finalize ⇒ Object
- #has_many(model) ⇒ Object
- #has_one(model) ⇒ Object
-
#initialize(&block) ⇒ RelationshipManager
constructor
A new instance of RelationshipManager.
- #the(left_model, &block) ⇒ Object
- #todo(method, *args) ⇒ Object
Constructor Details
#initialize(&block) ⇒ RelationshipManager
Returns a new instance of RelationshipManager.
31 32 33 |
# File 'lib/ramaze/contrib/sequel/relation.rb', line 31 def initialize(&block) instance_eval(&block) end |
Instance Method Details
#belongs_to(model) ⇒ Object
65 66 67 |
# File 'lib/ramaze/contrib/sequel/relation.rb', line 65 def belongs_to(model) todo :belongs_to, model.to_s.downcase.to_sym end |
#finalize ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ramaze/contrib/sequel/relation.rb', line 35 def finalize TODO.keys.each do |model| model.create_table unless model.table_exists? end TODO.each do |model, instructions| instructions.each do |args| model.send(*args) end end return # remove this line for debugging pp TODO TODO.keys.each do |model| puts "the #{model}" assoc = model.send(:association_reflections) assoc.each do |key, reflection| puts " #{reflection[:type]} => #{key}" end end end |
#has_many(model) ⇒ Object
69 70 71 72 |
# File 'lib/ramaze/contrib/sequel/relation.rb', line 69 def has_many(model) todo :create_join, model todo :many_to_many, model.to_s.downcase.pluralize.to_sym end |
#has_one(model) ⇒ Object
74 75 76 |
# File 'lib/ramaze/contrib/sequel/relation.rb', line 74 def has_one(model) todo :belongs_to, model.to_s.downcase.to_sym end |