Class: Sipity::Entity

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/sipity/entity.rb

Overview

A proxy for the entity that is being processed via workflows.

By using a proxy, we need not worry about polluting the proxy's concerns with things related to workflow processing.

The goal is to keep this behavior separate, so that we can possibly extract the information. workflow_id: 8, workflow_state_id: 20, created_at: “2017-07-07 13:39:42”, updated_at: “2017-07-07 13:39:42”>

Examples:

To get the Sipity::Entity for a work

work = GenericWork.first
work_global_id = Hyrax::GlobalID(work).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",

Instance Method Summary collapse

Instance Method Details

#proxy_forObject


38
39
40
# File 'app/models/sipity/entity.rb', line 38

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

#workflow_state_nameObject


31
32
33
# File 'app/models/sipity/entity.rb', line 31

def workflow_state_name
  workflow_state&.name
end