Class: Hydra::Config::PermissionsConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/hydra/config.rb

Direct Known Subclasses

InheritablePermissionsConfig

Defined Under Namespace

Classes: EmbargoConfig, GroupPermission, LeaseConfig

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePermissionsConfig

Returns a new instance of PermissionsConfig.



39
40
41
42
43
44
45
46
47
48
# File 'lib/hydra/config.rb', line 39

def initialize
  @values = {}
  [:discover, :read, :edit].each do |key|
    @values[key] = GroupPermission.new(
      group:      solr_name("#{prefix}#{key}_access_group", :symbol),
      individual: solr_name("#{prefix}#{key}_access_person", :symbol))
  end
  @embargo = EmbargoConfig.new({}, prefix: prefix)
  @lease = LeaseConfig.new({}, prefix: prefix)
end

Instance Attribute Details

#embargoObject

Returns the value of attribute embargo.



38
39
40
# File 'lib/hydra/config.rb', line 38

def embargo
  @embargo
end

#leaseObject

Returns the value of attribute lease.



38
39
40
# File 'lib/hydra/config.rb', line 38

def lease
  @lease
end

#policy_classObject

Returns the value of attribute policy_class.



38
39
40
# File 'lib/hydra/config.rb', line 38

def policy_class
  @policy_class
end

Instance Method Details

#[](key) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/hydra/config.rb', line 77

def [] key
  case key
    when :discover, :read, :edit
      @values[key]
    when :inheritable
      inheritable
    when :embargo_release_date
      Deprecation.warn PermissionsConfig, "[:embargo_release_date] is deprecated, use embargo.release_date= instead"
      embargo.release_date
    when :policy_class
      @policy_class
    else
      raise "Unknown key #{key}"
  end
end

#[]=(key, value) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/hydra/config.rb', line 59

def []= key, value
  case key
    when :discover, :read, :edit
      self.assign_value key, value
    when :inheritable
      inheritable.merge! value
    when :embargo_release_date
      Deprecation.warn PermissionsConfig, "[:embargo_release_date]= is deprecated, use embargo.release_date= instead"
      embargo.release_date = value
    when :policy_class
      self.policy_class = value
    when :owner
      logger.warn "':owner' is no longer a valid configuration for Hydra. Please remove it from your configuration."
    else
      raise "Unknown key `#{key.inspect}`"
  end
end

#discoverObject



97
98
99
# File 'lib/hydra/config.rb', line 97

def discover
  @values[:discover]
end

#discover=(val) ⇒ Object



109
110
111
# File 'lib/hydra/config.rb', line 109

def discover= val
  assign_value :discover, val
end

#editObject



105
106
107
# File 'lib/hydra/config.rb', line 105

def edit
  @values[:edit]
end

#edit=(val) ⇒ Object



117
118
119
# File 'lib/hydra/config.rb', line 117

def edit= val
  assign_value :edit, val
end

#embargo_release_dateObject



50
51
52
53
# File 'lib/hydra/config.rb', line 50

def embargo_release_date
  Deprecation.warn PermissionsConfig, "embargo_release_date is deprecated, use embargo.release_date instead"
  embargo.release_date
end

#inheritableObject



93
94
95
# File 'lib/hydra/config.rb', line 93

def inheritable
  @inheritable ||= InheritablePermissionsConfig.new
end

#merge!(values) ⇒ Object



55
56
57
# File 'lib/hydra/config.rb', line 55

def merge! values
  values.each {|k, v| self[k] = v }
end

#readObject



101
102
103
# File 'lib/hydra/config.rb', line 101

def read
  @values[:read]
end

#read=(val) ⇒ Object



113
114
115
# File 'lib/hydra/config.rb', line 113

def read= val
  assign_value :read, val
end