Sha256: 9c328232f49df80e58e7a84e6301e36c776801fcb8302a629b5dabf29d632e25

Contents?: true

Size: 591 Bytes

Versions: 16

Compression:

Stored size: 591 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

16 entries across 16 versions & 1 rubygems

Version Path
health-data-standards-4.3.5 lib/health-data-standards/models/reference.rb
health-data-standards-4.3.4 lib/health-data-standards/models/reference.rb
health-data-standards-4.3.3 lib/health-data-standards/models/reference.rb
health-data-standards-4.3.2 lib/health-data-standards/models/reference.rb
health-data-standards-4.3.1 lib/health-data-standards/models/reference.rb
health-data-standards-4.3.0 lib/health-data-standards/models/reference.rb
health-data-standards-4.2.0 lib/health-data-standards/models/reference.rb
health-data-standards-4.1.0 lib/health-data-standards/models/reference.rb
health-data-standards-4.0.6 lib/health-data-standards/models/reference.rb
health-data-standards-4.0.5 lib/health-data-standards/models/reference.rb
health-data-standards-4.0.4 lib/health-data-standards/models/reference.rb
health-data-standards-4.0.3 lib/health-data-standards/models/reference.rb
health-data-standards-4.0.2 lib/health-data-standards/models/reference.rb
health-data-standards-4.0.1 lib/health-data-standards/models/reference.rb
health-data-standards-4.0.0 lib/health-data-standards/models/reference.rb
health-data-standards-3.7.0 lib/health-data-standards/models/reference.rb