lib/authorized_persona/persona.rb
# Configure the authorization tiers in my_tier_slug: "My Tier Title And Description" form from lowest to highest privilege.
Configure the authorization tiers in my_tier_slug: "My Tier Title And Description" form from lowest to highest privilege.
Configure the authorization tiers in my_tier_slug : " My Tier Title And Description " form from lowest to highest privilege .
def authorization_tiers(tiers) 
        raise AuthorizedPersona::Error, "you can only define authorization tiers once" if instance_variable_defined?(:@authorization_tiers)
        if !tiers.is_a?(Hash) || !tiers.all? { |k, v| k.is_a?(Symbol) && v.is_a?(String) }
          raise('you must provide a hash of symbol tier names and string descriptions, e.g. " +
            trainee: "Trainee - limited access", staff: "Staff - regular access", admin: "Admin - full access"')
        end
        instance_methods = Module.new
        include instance_methods
        instance_methods.module_eval do
          tiers.keys.each do |tier|
            define_method "#{tier}_or_above?" do
              authorization_tier_at_or_above?(tier)
            end
          end
        end
        if respond_to?(:with_authorization_tier_at_or_above)
          class_methods = Module.new
          extend class_methods
          class_methods.module_eval do
            tiers.keys.each do |tier|
              define_method "#{tier}_or_above" do
                with_authorization_tier_at_or_above(tier)
              end
            end
          end
        end
        @authorization_tiers = tiers.freeze
      end
def authorization_tiers ( tiers ) raise AuthorizedPersona :: Error , "you can only define authorization tiers once" if instance_variable_defined? ( :@authorization_tiers ) if ! tiers . is_a? ( Hash ) || ! tiers . all? { | k , v | k . is_a? ( Symbol ) && v . is_a? ( String ) } raise ( 'you must provide a hash of symbol tier names and string descriptions, e.g. " +
            trainee: "Trainee - limited access", staff: "Staff - regular access", admin: "Admin - full access"' ) end instance_methods = Module . new include instance_methods instance_methods . module_eval do tiers . keys . each do | tier | define_method "#{tier}_or_above?" do authorization_tier_at_or_above? ( tier ) end end end if respond_to? ( :with_authorization_tier_at_or_above ) class_methods = Module . new extend class_methods class_methods . module_eval do tiers . keys . each do | tier | define_method "#{tier}_or_above" do with_authorization_tier_at_or_above ( tier ) end end end end @authorization_tiers = tiers . freeze end
Configure the authorization tiers in my_tier_slug: "My Tier Title And Description" form from lowest to highest privilege.
Configure the authorization tiers in my_tier_slug : " My Tier Title And Description " form from lowest to highest privilege .
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
tiers
<not_specific>