Class: Hyrax::Actors::InterpretVisibilityActor::Intention

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

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Intention

Returns a new instance of Intention.


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

def initialize(attributes)
  @attributes = attributes
end

Instance Method Details

#embargo_paramsObject


46
47
48
49
50
# File 'app/actors/hyrax/actors/interpret_visibility_actor.rb', line 46

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

#lease_paramsObject


40
41
42
43
44
# File 'app/actors/hyrax/actors/interpret_visibility_actor.rb', line 40

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.


12
13
14
15
16
17
18
19
20
21
22
# File 'app/actors/hyrax/actors/interpret_visibility_actor.rb', line 12

def sanitize_params
  if valid_lease?
    sanitize_lease_params
  elsif valid_embargo?
    sanitize_embargo_params
  elsif !wants_lease? && !wants_embargo?
    sanitize_unrestricted_params
  else
    @attributes
  end
end

#valid_embargo?Boolean

Returns:

  • (Boolean)

36
37
38
# File 'app/actors/hyrax/actors/interpret_visibility_actor.rb', line 36

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

#valid_lease?Boolean

Returns:

  • (Boolean)

32
33
34
# File 'app/actors/hyrax/actors/interpret_visibility_actor.rb', line 32

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

#wants_embargo?Boolean

Returns:

  • (Boolean)

28
29
30
# File 'app/actors/hyrax/actors/interpret_visibility_actor.rb', line 28

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

#wants_lease?Boolean

Returns:

  • (Boolean)

24
25
26
# File 'app/actors/hyrax/actors/interpret_visibility_actor.rb', line 24

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