Sha256: 8afc547ba6e034ad74d125c56035b68b6ddcdec7a59f05dc1fcafceb6210b33c

Contents?: true

Size: 1017 Bytes

Versions: 1

Compression:

Stored size: 1017 Bytes

Contents

module IAmICan
  module Role
    module Helpers
      module Cls
        def _to_store_role name, **options
          return false if ii_config.role_model.exists?(name: name) || ii_config.role_group_model.exists?(name: name)
          ii_config.role_model.create!(name: name, **options)
        end

        def _role_definition_result(names, failed_items)
          prefix = 'Role Definition Done'
          fail_msg = prefix + ", but name #{failed_items} have been used by other role or group" if failed_items.present?
          raise Error, fail_msg if ii_config.strict_mode && fail_msg
          fail_msg ? fail_msg : prefix
        end
      end

      module Ins
        def _role_assignment_result(names, failed_items)
          prefix = 'Role Assignment Done'
          fail_msg = prefix + ", but #{failed_items} have not been defined" if failed_items.present?
          raise Error, fail_msg if ii_config.strict_mode && fail_msg
          fail_msg ? fail_msg : prefix
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
i_am_i_can-2.1.0 lib/i_am_i_can/role/helpers.rb