Class: Sipity::Agent
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Sipity::Agent
- Defined in:
- app/models/sipity/agent.rb
Overview
A proxy for something that can take an action.
-
A User can be an agent
-
A Group can be an agent (though Group is outside the scope of this system)
Constant Summary collapse
- ENTITY_LEVEL_AGENT_RELATIONSHIP =
'entity_level'.freeze
- WORKFLOW_LEVEL_AGENT_RELATIONSHIP =
'workflow_level'.freeze
Instance Method Summary collapse
- #proxy_for ⇒ Object
-
#proxy_for=(target) ⇒ Object
Presently Hyrax::Group is a PORO not an ActiveRecord object, so creating a belongs to causes Rails 5.1 to try to access methods that don’t exist.
Instance Method Details
#proxy_for ⇒ Object
30 31 32 |
# File 'app/models/sipity/agent.rb', line 30 def proxy_for @proxy_for ||= proxy_for_type.constantize.find(proxy_for_id) end |
#proxy_for=(target) ⇒ Object
Presently Hyrax::Group is a PORO not an ActiveRecord object, so creating a belongs to causes Rails 5.1 to try to access methods that don’t exist. We do have this relationship, abet only conceptually: belongs_to :proxy_for, polymorphic: true
25 26 27 28 |
# File 'app/models/sipity/agent.rb', line 25 def proxy_for=(target) self.proxy_for_id = target.id self.proxy_for_type = target.class.name end |