class Shoulda::Matchers::ActiveRecord::Uniqueness::TestModelCreator

@private

Attributes

model_name[R]
namespace[R]

Public Class Methods

create(model_name, namespace) click to toggle source
# File lib/shoulda/matchers/active_record/uniqueness/test_model_creator.rb, line 10
def self.create(model_name, namespace)
  Mutex.new.synchronize do
    new(model_name, namespace).create
  end
end
new(model_name, namespace) click to toggle source
# File lib/shoulda/matchers/active_record/uniqueness/test_model_creator.rb, line 16
def initialize(model_name, namespace)
  @model_name = model_name
  @namespace = namespace
end

Public Instance Methods

create() click to toggle source
# File lib/shoulda/matchers/active_record/uniqueness/test_model_creator.rb, line 21
def create
  new_model.tap do |new_model|
    new_model.symlink_to(existing_model)
  end
end

Private Instance Methods

existing_model() click to toggle source
# File lib/shoulda/matchers/active_record/uniqueness/test_model_creator.rb, line 44
def existing_model
  @_existing_model ||= model_name.constantize
end
model_name_without_namespace() click to toggle source
# File lib/shoulda/matchers/active_record/uniqueness/test_model_creator.rb, line 33
def model_name_without_namespace
  model_name.demodulize
end
new_model() click to toggle source
# File lib/shoulda/matchers/active_record/uniqueness/test_model_creator.rb, line 37
def new_model
  @_new_model ||= Model.next_unique_copy_of(
    model_name_without_namespace,
    namespace
  )
end