| Module | Kernel |
| In: |
lib/ribs.rb
lib/ribs/repository.rb |
Gets a Repository object for the object in question. If the object is a class, the repository returned will be a Repository::Class, otherwise it will be a Repository::Instance. Specifically, what you will get for the class FooBar will be the class Ribs::Repository::DB_default::FooBar and you will get an instance of that class if the object is an instance of FooBar. This allows you to add specific functionality to these repositories. The class Ribs::Repository::DB_default::FooBar will also include Ribs::Repository::FooBar and extend Ribs::Repository::FooBar::ClassMethods so you can add behavior to these that map over all databases.
# File lib/ribs/repository.rb, line 240
240: def R(obj, db=:default)
241: Ribs::Repository(obj, db)
242: end
The main method for defining a Ribs model object can be used either from inside the class to define it on, or outside by providing a parameter for the class to act on. This gives some flexibility about where definitions should go. The implementation also keeps it open whether the model class is a real class or a singleton class. The end result of calling the Ribs! method will be to generate a definition for a database mapping, based on the information provided inside the optional block. The block will yield an object of type Ribs::Rib.
user_options currently takes these parameters:
# File lib/ribs.rb, line 94
94: def Ribs!(user_options = {}, &block)
95: default_options = {:on => self, :db => :default, :from => nil}
96: options = default_options.merge user_options
97: Ribs::define_ribs(options[:on], options, &block)
98: end