Sha256: 4e086e1c1ea1ac3bd0df95287f26ff68d2987dd92db8798415ef0bcbdbf98177

Contents?: true

Size: 1.76 KB

Versions: 2

Compression:

Stored size: 1.76 KB

Contents

module Popolo
  # An occurrence, e.g. an action mentioning or performed by an agent.
  #
  # Turtle document: @todo move into popoloproject.com
  #
  #     <http://example.com/events/57cc67093475061e3d95369d.ttl>
  #       a cnt:ContentAsText;
  #       cnt:characterEncoding "UTF-8";
  #       cnt:chars "Lorem ipsum dolor sit amet, consectetur adipiscing elit. ...";
  #       dcterms:format "text/plain";
  #       dcterms:isFormatOf <http://example.org/news/123.html>;
  #       dcterms:issued "2012-01-01T00:00:00Z"^^xsd:dateTime;
  #       dcterms:identifier "57cc67093475061e3d95369d";
  #       dcterms:created "2012-01-01T00:00:00Z"^^xsd:dateTime;
  #       dcterms:modified "2012-01-01T00:00:00Z"^^xsd:dateTime .
  #
  # @see http://www.w3.org/TR/Content-in-RDF10/
  # @see http://dublincore.org/documents/dcmi-terms/
  class Event
    include Mongoid::Document
    include Mongoid::Timestamps

    # The identifier of the source of information for the event.
    field :source, type: String
    # The URL to which the event may be attributed.
    field :url, type: String
    # The event's content.
    field :body, type: String
    # The time of the event or of its publication.
    field :issued_at, type: Time
    # The records related to the event.
    field :related, type: Hash
    # Any additional information about the event.
    field :extra, type: Hash

    # @note It's not possible to do a many-to-many polymorphic relation, so we
    #   must list every index individually.

    index 'related.area' => 1, source: 1, issued_at: -1
    index 'related.membership' => 1, source: 1, issued_at: -1
    index 'related.organization' => 1, source: 1, issued_at: -1
    index 'related.post' => 1, source: 1, issued_at: -1

    validates_presence_of :source, :url, :body, :issued_at
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
popolo-0.0.2 app/models/popolo/event.rb
popolo-0.0.1 app/models/popolo/event.rb