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



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/hydra/config.rb', line 69

def [] key
  case key
    when :discover, :read, :edit
      @values[key]
    when :inheritable
      inheritable
    when :policy_class
      @policy_class
    else
      raise "Unknown key #{key}"
  end
end

#[]=(key, value) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/hydra/config.rb', line 54

def []= key, value
  case key
    when :discover, :read, :edit
      self.assign_value key, value
    when :inheritable
      inheritable.merge! value
    when :policy_class
      self.policy_class = value
    when :owner
      Rails.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



86
87
88
# File 'lib/hydra/config.rb', line 86

def discover
  @values[:discover]
end

#discover=(val) ⇒ Object



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

def discover= val
  assign_value :discover, val
end

#editObject



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

def edit
  @values[:edit]
end

#edit=(val) ⇒ Object



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

def edit= val
  assign_value :edit, val
end

#inheritableObject



82
83
84
# File 'lib/hydra/config.rb', line 82

def inheritable
  @inheritable ||= InheritablePermissionsConfig.new
end

#merge!(values) ⇒ Object



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

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

#readObject



90
91
92
# File 'lib/hydra/config.rb', line 90

def read
  @values[:read]
end

#read=(val) ⇒ Object



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

def read= val
  assign_value :read, val
end