Sha256: 08f43b5bba5c840fa6281dfd538532ef3685139f25cc16159db2d9b48bb743da

Contents?: true

Size: 1.49 KB

Versions: 24

Compression:

Stored size: 1.49 KB

Contents

module Sipity
  # A proxy for the entity that is being processed.
  # By using a proxy, we need not worry about polluting the proxy's concerns
  # with things related to processing.
  #
  # The goal is to keep this behavior separate, so that we can possibly
  # extract the information.
  # @example To get the Sipity::Entity for a work
  #   work = GenericWork.first
  #   work_global_id = work.to_global_id.to_s
  #   => "gid://whatever/GenericWork/3x816m604"
  #   Sipity::Entity.where(proxy_for_global_id: work_global_id).first
  #   => #<Sipity::Entity id: 1, proxy_for_global_id: "gid://whatever/GenericWork/3x816m604",
  # workflow_id: 8, workflow_state_id: 20, created_at: "2017-07-07 13:39:42", updated_at: "2017-07-07 13:39:42">
  class Entity < ActiveRecord::Base
    self.table_name = 'sipity_entities'

    belongs_to :workflow, class_name: 'Sipity::Workflow'
    belongs_to :workflow_state,
               optional: true,
               class_name: 'Sipity::WorkflowState'

    has_many :entity_specific_responsibilities, dependent: :destroy, class_name: 'Sipity::EntitySpecificResponsibility'

    has_many :comments,
             foreign_key: :entity_id,
             dependent: :destroy,
             class_name: 'Sipity::Comment'

    def workflow_state_name
      workflow_state.name if workflow_state
    end

    # Defines the method #workflow_name
    delegate :name, to: :workflow, prefix: :workflow

    def proxy_for
      @proxy_for ||= GlobalID::Locator.locate(proxy_for_global_id)
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
hyrax-1.1.1 app/models/sipity/entity.rb
hyrax-2.0.3 app/models/sipity/entity.rb
hyrax-2.1.0 app/models/sipity/entity.rb
hyrax-2.1.0.rc4 app/models/sipity/entity.rb
hyrax-2.1.0.rc3 app/models/sipity/entity.rb
hyrax-2.1.0.rc2 app/models/sipity/entity.rb
hyrax-2.1.0.rc1 app/models/sipity/entity.rb
hyrax-1.1.0 app/models/sipity/entity.rb
hyrax-2.1.0.beta2 app/models/sipity/entity.rb
hyrax-2.0.2 app/models/sipity/entity.rb
hyrax-2.1.0.beta1 app/models/sipity/entity.rb
hyrax-2.0.1 app/models/sipity/entity.rb
hyrax-2.0.0 app/models/sipity/entity.rb
hyrax-2.0.0.rc3 app/models/sipity/entity.rb
hyrax-2.0.0.rc2 app/models/sipity/entity.rb
hyrax-2.0.0.rc1 app/models/sipity/entity.rb
hyrax-1.0.5 app/models/sipity/entity.rb
hyrax-2.0.0.beta5 app/models/sipity/entity.rb
hyrax-2.0.0.beta4 app/models/sipity/entity.rb
hyrax-2.0.0.beta3 app/models/sipity/entity.rb