Class: Necropsy::ResolutionRecord

Inherits:
Data
  • Object
show all
Defined in:
lib/necropsy/models.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resolution:, producer:, producer_version: nil, assumptions: []) ⇒ ResolutionRecord

Returns a new instance of ResolutionRecord.



242
243
244
245
246
247
248
# File 'lib/necropsy/models.rb', line 242

def initialize(resolution:, producer:, producer_version: nil, assumptions: [])
  resolution = normalize_resolution(resolution)
  producer = ModelNormalization.identifier(producer, 'producer')
  producer_version = ModelNormalization.identifier(producer_version, 'producer_version') if producer_version
  assumptions = ModelNormalization.string_list(assumptions, 'assumption')
  super
end

Instance Attribute Details

#assumptionsObject (readonly)

Returns the value of attribute assumptions

Returns:

  • (Object)

    the current value of assumptions



241
242
243
# File 'lib/necropsy/models.rb', line 241

def assumptions
  @assumptions
end

#producerObject (readonly)

Returns the value of attribute producer

Returns:

  • (Object)

    the current value of producer



241
242
243
# File 'lib/necropsy/models.rb', line 241

def producer
  @producer
end

#producer_versionObject (readonly)

Returns the value of attribute producer_version

Returns:

  • (Object)

    the current value of producer_version



241
242
243
# File 'lib/necropsy/models.rb', line 241

def producer_version
  @producer_version
end

#resolutionObject (readonly)

Returns the value of attribute resolution

Returns:

  • (Object)

    the current value of resolution



241
242
243
# File 'lib/necropsy/models.rb', line 241

def resolution
  @resolution
end

Class Method Details

.from_h(attributes) ⇒ Object



250
251
252
253
254
255
256
257
258
# File 'lib/necropsy/models.rb', line 250

def self.from_h(attributes)
  data = ModelNormalization.attributes(attributes, name)
  new(
    resolution: data.fetch('resolution'),
    producer: data.fetch('producer'),
    producer_version: data['producer_version'],
    assumptions: data.fetch('assumptions', [])
  )
end

Instance Method Details

#identity_keyObject



260
261
262
# File 'lib/necropsy/models.rb', line 260

def identity_key
  [resolution.call_site_id, producer, producer_version, assumptions].freeze
end

#to_hObject



264
265
266
267
268
269
270
271
# File 'lib/necropsy/models.rb', line 264

def to_h
  {
    'resolution' => resolution.to_h,
    'producer' => producer,
    'producer_version' => producer_version,
    'assumptions' => assumptions
  }
end