lib/fixtury/reference.rb in fixtury-0.4.1 vs lib/fixtury/reference.rb in fixtury-1.0.0.beta1
- old
+ new
@@ -1,30 +1,32 @@
# frozen_string_literal: true
module Fixtury
+ # Acts as an reference between the schema and an object in some remote store.
+ # The Store uses these references to keep track of the fixtures it has created.
+ # The references are used by the locator to retrieve the fixture data from whatever
+ # backend is being used.
class Reference
- HOLDER_VALUE = "__BUILDING_FIXTURE__"
+ # A special key used to indicate that the a definition is currently building an
+ # object for this locator_key. This is used to prevent circular dependencies.
+ HOLDER_KEY = "__BUILDING_FIXTURE__"
def self.holder(name)
- new(name, HOLDER_VALUE)
+ new(name, HOLDER_KEY)
end
- def self.create(name, value)
- new(name, value)
- end
+ attr_reader :name, :locator_key, :created_at, :options
- attr_reader :name, :value, :created_at, :options
-
- def initialize(name, value, options = {})
+ def initialize(name, locator_key, options = {})
@name = name
- @value = value
+ @locator_key = locator_key
@created_at = Time.now.to_i
@options = options
end
def holder?
- value == HOLDER_VALUE
+ locator_key == HOLDER_KEY
end
def real?
!holder?
end