Sha256: 7255f2d12dc539f6dff4c67bda1dc8e93b23242240376c3c0ae5d3b6c0285a59

Contents?: true

Size: 590 Bytes

Versions: 1

Compression:

Stored size: 590 Bytes

Contents

class Reference
  include Mongoid::Document
  include Mongoid::Attributes::Dynamic
  embedded_in :entry
  field :type, type: String
  field :referenced_type, type: String
  field :referenced_id

  def resolve_reference
    entry.record.entries.find do |e|
      e.class.to_s == referenced_type &&
      e.identifier.to_s == referenced_id.to_s
    end
  end

  def resolve_referenced_id
    resolved_reference = entry.record.entries.find do |e|
      e.class.to_s == referenced_type &&
      e.identifier == referenced_id
    end
    self.referenced_id = resolved_reference.id.to_s
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
health-data-standards-3.6.1 lib/health-data-standards/models/reference.rb