Module: Shoegaze::Datastore

Defined in:
lib/shoegaze/datastore.rb

Instance Method Summary collapse

Instance Method Details

#datastore(name, &block) ⇒ Class

Defines both a TopModel-inherited class and a factory in the mock namespace

example:

datastore :User do
  id 123
  name "Karlita"
end

Parameters:

  • name (Symbol)

    upcased name of the datastore to create (example: :User)

  • block (Block)

    FactoryGirl factory implementation expressed in a block

Returns:

  • (Class)

    the created datastore class


16
17
18
19
20
21
22
23
24
25
26
# File 'lib/shoegaze/datastore.rb', line 16

def datastore(name, &block)
  klass = create_datastore_class(name)

  FactoryGirl.define do
    factory klass do
      self.instance_eval(&block)
    end
  end

  klass
end