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'
- WORKFLOW_LEVEL_AGENT_RELATIONSHIP =
'workflow_level'
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
31 32 33 |
# File 'app/models/sipity/agent.rb', line 31 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
26 27 28 29 |
# File 'app/models/sipity/agent.rb', line 26 def proxy_for=(target) self.proxy_for_id = target.id self.proxy_for_type = target.class.name end |