Class: Fixtury::Reference

Inherits:
Object
  • Object
show all
Defined in:
lib/fixtury/reference.rb

Overview

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.

Constant Summary collapse

HOLDER_KEY =

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.

"__BUILDING_FIXTURE__"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, locator_key, **metadata) ⇒ Reference

Returns a new instance of Reference.



21
22
23
24
25
26
# File 'lib/fixtury/reference.rb', line 21

def initialize(name, locator_key, **)
  @name = name
  @locator_key = locator_key
  @created_at = Time.now.to_i
  @metadata = 
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



18
19
20
# File 'lib/fixtury/reference.rb', line 18

def created_at
  @created_at
end

#locator_keyObject (readonly)

Returns the value of attribute locator_key.



18
19
20
# File 'lib/fixtury/reference.rb', line 18

def locator_key
  @locator_key
end

#metadataObject (readonly) Also known as: options

Returns the value of attribute metadata.



18
19
20
# File 'lib/fixtury/reference.rb', line 18

def 
  @metadata
end

#nameObject (readonly)

Returns the value of attribute name.



18
19
20
# File 'lib/fixtury/reference.rb', line 18

def name
  @name
end

Class Method Details

.holder(name) ⇒ Object



14
15
16
# File 'lib/fixtury/reference.rb', line 14

def self.holder(name)
  new(name, HOLDER_KEY)
end

Instance Method Details

#holder?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/fixtury/reference.rb', line 28

def holder?
  locator_key == HOLDER_KEY
end

#real?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/fixtury/reference.rb', line 32

def real?
  !holder?
end