Sha256: af125dc2b1f32dc008ccdf5edfbd9dbd70276de0bdeef251d243c25c84723945

Contents?: true

Size: 541 Bytes

Versions: 3

Compression:

Stored size: 541 Bytes

Contents

module FastSeeder
  module Seeders
    class InlineSeeder < BaseSeeder
      class DataContext
	attr_reader :records

	def initialize(data_block)
	  @records = []
	  instance_eval(&data_block)
	end

	def record(*args)
	  @records << args
	end
      end


      def initialize(model_class, declared_columns, default_values, data_block)
	super(model_class, declared_columns, default_values)
	@data_block       = data_block
      end


      private

      def specific_values
	DataContext.new(@data_block).records
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fast_seeder-0.1.0 lib/fast_seeder/seeders/inline_seeder.rb
fast_seeder-0.0.2 lib/fast_seeder/seeders/inline_seeder.rb
fast_seeder-0.0.1 lib/fast_seeder/seeders/inline_seeder.rb