Module: Sequel::Plugins::DefaultsSetter
- Defined in:
- lib/sequel/plugins/defaults_setter.rb
Overview
DefaultsSetter is a simple plugin that sets non-nil/NULL default values upon initialize:
# column a default NULL
# column b default 2
album = Album.new.values # {:b => 2}
album = Album.new(:a=>1, :b=>3).values # {:a => 1, :b => 3}
Usage:
# Make all model subclass instances set defaults (called before loading subclasses)
Sequel::Model.plugin :defaults_setter
# Make the Album class set defaults
Album.plugin :defaults_setter
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary collapse
-
.configure(model) ⇒ Object
Set the default values based on the model schema.
Class Method Details
.configure(model) ⇒ Object
Set the default values based on the model schema
20 21 22 |
# File 'lib/sequel/plugins/defaults_setter.rb', line 20 def self.configure(model) model.send(:set_default_values) end |