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.



202
203
204
# File 'lib/sinja/config.rb', line 202

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

Instance Method Details

#==(other) ⇒ Object



208
209
210
# File 'lib/sinja/config.rb', line 208

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

#freezeObject



226
227
228
229
# File 'lib/sinja/config.rb', line 226

def freeze
  deep_freeze(@data)
  super
end

#initialize_copy(other) ⇒ Object



221
222
223
224
# File 'lib/sinja/config.rb', line 221

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

#merge!(h = {}) ⇒ Object



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

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