Class: Sinja::RolesConfig

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
ConfigUtils
Defined in:
lib/sinja/config.rb

Instance Method Summary collapse

Methods included from ConfigUtils

#deep_copy, #deep_freeze

Constructor Details

#initialize(actions = []) ⇒ RolesConfig

Returns a new instance of RolesConfig.



200
201
202
# File 'lib/sinja/config.rb', line 200

def initialize(actions=[])
  @data = actions.map { |action| [action, Roles.new] }.to_h
end

Instance Method Details

#==(other) ⇒ Object



206
207
208
# File 'lib/sinja/config.rb', line 206

def ==(other)
  @data == other.instance_variable_get(:@data)
end

#freezeObject



224
225
226
227
# File 'lib/sinja/config.rb', line 224

def freeze
  deep_freeze(@data)
  super
end

#initialize_copy(other) ⇒ Object



219
220
221
222
# File 'lib/sinja/config.rb', line 219

def initialize_copy(other)
  super
  @data = deep_copy(other.instance_variable_get(:@data))
end

#merge!(h = {}) ⇒ Object



210
211
212
213
214
215
216
217
# File 'lib/sinja/config.rb', line 210

def merge!(h={})
  h.each do |action, roles|
    abort "Unknown or invalid action helper `#{action}' in configuration" \
      unless @data.key?(action)
    @data[action].replace([*roles])
  end
  @data
end