Sha256: 8d4b9400534b3c96dd8b77f64a5bc65309bd92f18f1cdc613bf0c5aad0f549c2

Contents?: true

Size: 604 Bytes

Versions: 2

Compression:

Stored size: 604 Bytes

Contents

# frozen_string_literal: true

require 'i_am_i_can/configs/config'

module IAmICan
  module Configs
    cattr_accessor :configs, default: { }

    def self.set_for(subject:, role:, permission:, role_group: nil, &block)
      config = Config.new(subject, role, permission, role_group)
      config.instance_eval(&block)
      configs.merge!(
          subject => config.dup,
          role => config.dup,
          permission => config.dup,
      )
      configs.merge!(role_group => config.dup) if role_group
      config
    end

    def self.get(class_name)
      configs[class_name]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
i_am_i_can-4.4.1 lib/i_am_i_can/configs/configs.rb
i_am_i_can-4.4.0 lib/i_am_i_can/configs/configs.rb