popolo-project/popolo-engine

View on GitHub
app/models/popolo/link.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Popolo
  # A URL.
  class Link
    include Mongoid::Document

    embedded_in :linkable, polymorphic: true

    # A URL.
    field :url, type: String
    # A note, e.g. 'Wikipedia page'.
    field :note, type: String

    validates_presence_of :url
    # @note Add URL validation to match JSON Schema?

    def to_s
      note || url
    end
  end
end