Class: Sipity::Policies::EnrichSipByFormSubmissionPolicy

Inherits:
BasePolicy
  • Object
show all
Defined in:
app/policies/sipity/policies/enrich_sip_by_form_submission_policy.rb

Overview

Responsible for enforcing Assignment of a DOI

See Also:

Instance Attribute Summary collapse

Attributes inherited from BasePolicy

#entity, #user

Instance Method Summary collapse

Methods inherited from BasePolicy

#available_actions_by_policy, call, define_policy_question, #registered_policy_questions, #registered_policy_questions?

Constructor Details

#initialize(user, entity, options = {}) ⇒ EnrichSipByFormSubmissionPolicy


11
12
13
14
# File 'app/policies/sipity/policies/enrich_sip_by_form_submission_policy.rb', line 11

def initialize(user, entity, options = {})
  super(user, entity)
  @sip_policy = options.fetch(:sip_policy) { default_sip_policy }
end

Instance Attribute Details

#sip_policyObject (readonly, private)

Returns the value of attribute sip_policy


9
10
11
# File 'app/policies/sipity/policies/enrich_sip_by_form_submission_policy.rb', line 9

def sip_policy
  @sip_policy
end

Instance Method Details

#default_sip_policyObject (private)


32
33
34
# File 'app/policies/sipity/policies/enrich_sip_by_form_submission_policy.rb', line 32

def default_sip_policy
  SipPolicy.new(user, entity.sip)
end

#entity=(object) ⇒ Object (private)


24
25
26
27
28
29
30
# File 'app/policies/sipity/policies/enrich_sip_by_form_submission_policy.rb', line 24

def entity=(object)
  if object.respond_to?(:sip) && object.sip.present?
    super(object)
  else
    fail Exceptions::PolicyEntityExpectationError, "Expected #{object} to have a #sip."
  end
end