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.



53
54
55
56
57
58
59
60
61
62
# File 'lib/hydra/config.rb', line 53

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.



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

def embargo
  @embargo
end

#leaseObject

Returns the value of attribute lease.



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

def lease
  @lease
end

#policy_classObject

Returns the value of attribute policy_class.



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

def policy_class
  @policy_class
end

Instance Method Details

#[](key) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/hydra/config.rb', line 83

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



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

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



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

def discover
  @values[:discover]
end

#discover=(val) ⇒ Object



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

def discover= val
  assign_value :discover, val
end

#editObject



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

def edit
  @values[:edit]
end

#edit=(val) ⇒ Object



120
121
122
# File 'lib/hydra/config.rb', line 120

def edit= val
  assign_value :edit, val
end

#inheritableObject



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

def inheritable
  @inheritable ||= InheritablePermissionsConfig.new
end

#merge!(values) ⇒ Object



64
65
66
# File 'lib/hydra/config.rb', line 64

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

#readObject



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

def read
  @values[:read]
end

#read=(val) ⇒ Object



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

def read= val
  assign_value :read, val
end