Class: LazyFixtures::Generator

Inherits:
Object
  • Object
show all
Includes:
ObjectHelper
Defined in:
lib/lazy_fixtures/generator.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
    nested:      false,
    overwrite:   false,
    create:      true,
    parent:      [],
    skip_attr:   [],
    change_attr: {}
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ObjectHelper

#get_object, #invalid_object?

Constructor Details

#initialize(object, options = {}) ⇒ Generator

Returns a new instance of Generator.



17
18
19
20
# File 'lib/lazy_fixtures/generator.rb', line 17

def initialize(object, options = {})
  @options = DEFAULT_OPTIONS.merge(options)
  @object = get_object(object)
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



6
7
8
# File 'lib/lazy_fixtures/generator.rb', line 6

def object
  @object
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/lazy_fixtures/generator.rb', line 6

def options
  @options
end

Instance Method Details

#generate(type) ⇒ Object



22
23
24
# File 'lib/lazy_fixtures/generator.rb', line 22

def generate(type)
  gather_class(type).new(object, options).generate
end