Class: Sow::Sower

Inherits:
Object
  • Object
show all
Defined in:
lib/seed_drill.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, fixed_fields = nil, &block) ⇒ Sower

Returns a new instance of Sower


21
22
23
24
25
26
27
28
# File 'lib/seed_drill.rb', line 21

def initialize(klass, fixed_fields = nil, &block)
  fields = Fields.new(fixed_fields, &block)
  adapter = Adapter.get(klass)
  @model = adapter.first_or_create(fields.fixed)
  adapter.update_attributes(model, fields.variant)
  adapter.update_associations(model, fields.proc)
  model.save
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model


19
20
21
# File 'lib/seed_drill.rb', line 19

def model
  @model
end