Class: CurationConcerns::Actors::InterpretVisibilityActor::Intention

Inherits:
Object
  • Object
show all
Defined in:
app/actors/curation_concerns/actors/interpret_visibility_actor.rb

Overview

Since:

  • 0.14.0

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Intention

Returns a new instance of Intention.

Since:

  • 0.14.0



5
6
7
# File 'app/actors/curation_concerns/actors/interpret_visibility_actor.rb', line 5

def initialize(attributes)
  @attributes = attributes
end

Instance Method Details

#embargo_paramsObject

Since:

  • 0.14.0



57
58
59
60
61
# File 'app/actors/curation_concerns/actors/interpret_visibility_actor.rb', line 57

def embargo_params
  [:embargo_release_date,
   :visibility_during_embargo,
   :visibility_after_embargo].map { |key| @attributes[key] }
end

#lease_paramsObject

Since:

  • 0.14.0



51
52
53
54
55
# File 'app/actors/curation_concerns/actors/interpret_visibility_actor.rb', line 51

def lease_params
  [:lease_expiration_date,
   :visibility_during_lease,
   :visibility_after_lease].map { |key| @attributes[key] }
end

#sanitize_paramsObject

returns a copy of attributes with the necessary params removed If the lease or embargo is valid, or if they selected something besides lease or embargo, remove all the params.

Since:

  • 0.14.0



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/actors/curation_concerns/actors/interpret_visibility_actor.rb', line 12

def sanitize_params
  if valid_lease?
    @attributes.except(:visibility,
                       :embargo_release_date,
                       :visibility_during_embargo,
                       :visibility_after_embargo)
  elsif valid_embargo?
    @attributes.except(:visibility,
                       :lease_expiration_date,
                       :visibility_during_lease,
                       :visibility_after_lease)
  elsif !wants_lease? && !wants_embargo?
    @attributes.except(:lease_expiration_date,
                       :visibility_during_lease,
                       :visibility_after_lease,
                       :embargo_release_date,
                       :visibility_during_embargo,
                       :visibility_after_embargo)
  else
    @attributes
  end
end

#valid_embargo?Boolean

Returns:

  • (Boolean)

Since:

  • 0.14.0



47
48
49
# File 'app/actors/curation_concerns/actors/interpret_visibility_actor.rb', line 47

def valid_embargo?
  wants_embargo? && @attributes[:embargo_release_date].present?
end

#valid_lease?Boolean

Returns:

  • (Boolean)

Since:

  • 0.14.0



43
44
45
# File 'app/actors/curation_concerns/actors/interpret_visibility_actor.rb', line 43

def valid_lease?
  wants_lease? && @attributes[:lease_expiration_date].present?
end

#wants_embargo?Boolean

Returns:

  • (Boolean)

Since:

  • 0.14.0



39
40
41
# File 'app/actors/curation_concerns/actors/interpret_visibility_actor.rb', line 39

def wants_embargo?
  visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_EMBARGO
end

#wants_lease?Boolean

Returns:

  • (Boolean)

Since:

  • 0.14.0



35
36
37
# File 'app/actors/curation_concerns/actors/interpret_visibility_actor.rb', line 35

def wants_lease?
  visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_LEASE
end