Sha256: 2e1a8c39a252f81c064e4802a406ddeadbe7290853fe6443d265152b08b2e5e8
Contents?: true
Size: 826 Bytes
Versions: 6
Compression:
Stored size: 826 Bytes
Contents
module ActsPermissive module PermissionMap class << self def const_set(*args) @@hash = nil super end def hash @@hash ||= begin bitwise_hash = constants.inject({}) do |hash, constant_name| hash[constant_name.downcase] = 2 ** ActsPermissive::PermissionMap.const_get(constant_name.to_sym) hash end inverted_hash = bitwise_hash.invert bitwise_hash.values.sort.inject(ActiveSupport::OrderedHash.new) do |hash, value| hash[inverted_hash[value].to_sym] = value hash end rescue TypeError raise ActsPermissive::PermissiveError.new("Permissions must be integers or longs. Strings, symbols, and floats are not currently supported.") end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems