On Nov 24, 7:28 pm, Sergio <[email protected]> wrote: > I am trying to understand how Sequel works. The example below inherit > from Sequel::Model and calls set_schema, create_table, etc. > > I was trying to find the documentation for these methods, but no luck > on the rdoc for > Sequel::Model:http://sequel.rubyforge.org/rdoc/classes/Sequel/Model.html > > Where are these methods coming from and how does Sequel::Model make > them available? > > class Task < Sequel::Model > set_schema do > primary_key :id > > varchar :title, :unique => true, :empty => false > boolean :done, :default => false > end > > create_table unless table_exists? > > if empty? > create :title => 'Laundry' > create :title => 'Wash dishes' > end > end
Those methods are in the schema plugin (http://sequel.rubyforge.org/ rdoc-plugins/classes/Sequel/Plugins/Schema/ClassMethods.html). To use them, you need to call plugin :schema before set_schema. My personal preference is use the Database create_table? method instead of using the schema plugin. The schema plugin is for backwards compatibility with Sequel 2. Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
