Sha256: 4bdfe7a391d105e14199ef8b3588836327715755d11a1b5344dcad0bdc55589e
Contents?: true
Size: 901 Bytes
Versions: 1
Compression:
Stored size: 901 Bytes
Contents
# TODO: Abstract this module more later module Permissive class PermissionError < StandardError; end; module Permissions 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 ** Permissive::Permissions.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 ArgumentError raise Permissive::PermissionError.new("Permissions must be integers or longs. Strings, symbols, and floats are not currently supported.") end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
permissive-0.0.1 | lib/permissive/permissions.rb |