Class: Sprig::Dependency
- Inherits:
-
Object
- Object
- Sprig::Dependency
- Defined in:
- lib/sprig/dependency.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(klass, sprig_id) ⇒ Dependency
constructor
A new instance of Dependency.
- #sprig_record_reference ⇒ Object
Constructor Details
#initialize(klass, sprig_id) ⇒ Dependency
Returns a new instance of Dependency.
12 13 14 15 16 17 18 |
# File 'lib/sprig/dependency.rb', line 12 def initialize(klass, sprig_id) @klass = klass @sprig_id = sprig_id @id = SecureRandom.uuid self.class.collection.set(klass, sprig_id, self) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/sprig/dependency.rb', line 3 def id @id end |
Class Method Details
.for(klass, sprig_id) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/sprig/dependency.rb', line 5 def self.for(klass, sprig_id) klass = to_klass(klass) sprig_id = sprig_id.to_s collection.get(klass, sprig_id) || new(klass, sprig_id) end |
Instance Method Details
#sprig_record_reference ⇒ Object
20 21 22 |
# File 'lib/sprig/dependency.rb', line 20 def sprig_record_reference "sprig_record(#{klass}, #{sprig_id})" end |