class Fixturator::Model

Attributes

excluded_attributes[R]
name[R]

Public Class Methods

new(hash) click to toggle source
Calls superclass method
# File lib/fixturator/model.rb, line 6
def new(hash)
  name = to_model(hash["name"]) or return nil

  hash["name"] = name
  super(hash)
end
new(hash) click to toggle source
# File lib/fixturator/model.rb, line 21
def initialize(hash)
  @name = hash.fetch("name")
  @excluded_attributes = hash.fetch("exclude", [])
end

Private Class Methods

to_model(name) click to toggle source
# File lib/fixturator/model.rb, line 15
def to_model(name)
  name = name.safe_constantize or return nil
  name.ancestors.include?(ActiveRecord::Base) ? name : nil
end

Public Instance Methods

to_fixture() click to toggle source
# File lib/fixturator/model.rb, line 28
def to_fixture
  Generator.new(name, excluded_attributes: excluded_attributes).call
end