Class: Upkeep::Dependencies::Identity

Inherits:
Base
  • Object
show all
Defined in:
lib/upkeep/dependencies.rb

Instance Attribute Summary

Attributes inherited from Base

#key, #metadata, #source

Instance Method Summary collapse

Methods inherited from Base

#cache_key, #matches_change?, #narrow_frame_safe?, #to_h

Constructor Details

#initialize(source:, key:, value:, metadata: {}, partitioning: nil, absent_by_name: nil) ⇒ Identity

Returns a new instance of Identity.



243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/upkeep/dependencies.rb', line 243

def initialize(source:, key:, value:, metadata: {}, partitioning: nil, absent_by_name: nil)
   = .dup
  [:partitioning_identity] = partitioning unless partitioning.nil?
  if absent_by_name&.any?
    [:identity_absent_by_name] = absent_by_name.to_h.transform_keys(&:to_s)
  end

  super(
    source: source,
    key: { key: key, value: value },
    metadata: 
  )
end

Instance Method Details

#identity?Boolean

Returns:

  • (Boolean)


257
258
259
# File 'lib/upkeep/dependencies.rb', line 257

def identity?
  true
end

#identity_keyObject



261
262
263
# File 'lib/upkeep/dependencies.rb', line 261

def identity_key
  { source: source, key: key.fetch(:key), value: key.fetch(:value) }
end

#nil_identity?Boolean

Returns:

  • (Boolean)


265
266
267
268
269
270
# File 'lib/upkeep/dependencies.rb', line 265

def nil_identity?
  return true if key.fetch(:value).nil?

  value_class = [:value_class] || ["value_class"]
  value_class.to_s == "NilClass"
end

#precisionObject



276
277
278
# File 'lib/upkeep/dependencies.rb', line 276

def precision
  :identity
end

#visibilityObject



272
273
274
# File 'lib/upkeep/dependencies.rb', line 272

def visibility
  :identity_bound
end