Sha256: 19432541cefd526e09da03accf36a01808310a49c337fa553bb5f421df8da5af

Contents?: true

Size: 600 Bytes

Versions: 1

Compression:

Stored size: 600 Bytes

Contents

require 'datamapper'

module DataMapper::Model
  # Creates a single record of seed data for use
  # with the db:seed rake task. 
  # 
  # === Parameters
  # constraints :: Immutable reference attributes. Defaults to :id
  def seed(*constraints, &block)
    MerbSeed::Seeder.plant(self, *constraints, &block)
  end

  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
  
  def column_names
    properties.map{|i| i.field }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
merb_seed-0.1.0 lib/merb_seed/orm/dm_ext.rb