Module: DataMapper::Model
- Defined in:
- lib/merb_seed/orm/dm_ext.rb
Instance Method Summary collapse
- #column_names ⇒ Object
-
#seed(*constraints, &block) ⇒ Object
Creates a single record of seed data for use with the db:seed rake task.
- #seed_many(*constraints) ⇒ Object
Instance Method Details
#column_names ⇒ Object
24 25 26 |
# File 'lib/merb_seed/orm/dm_ext.rb', line 24 def column_names properties.map{|i| i.field } end |
#seed(*constraints, &block) ⇒ Object
Creates a single record of seed data for use with the db:seed rake task.
Parameters
- constraints
-
Immutable reference attributes. Defaults to :id
9 10 11 |
# File 'lib/merb_seed/orm/dm_ext.rb', line 9 def seed(*constraints, &block) MerbSeed::Seeder.plant(self, *constraints, &block) end |
#seed_many(*constraints) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/merb_seed/orm/dm_ext.rb', line 13 def seed_many(*constraints) seeds = constraints.pop seeds.each do |seed_data| seed(*constraints) do |s| seed_data.each_pair do |k,v| s.send "#{k}=", v end end end end |