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.


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

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

Instance Method Details

#==(other) ⇒ Object


213
214
215
# File 'lib/sinja/config.rb', line 213

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

#freezeObject


231
232
233
234
# File 'lib/sinja/config.rb', line 231

def freeze
  deep_freeze(@data)
  super
end

#initialize_copy(other) ⇒ Object


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

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

#merge!(h = {}) ⇒ Object


217
218
219
220
221
222
223
224
# File 'lib/sinja/config.rb', line 217

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