Sha256: 3df4229c8235c5c293eb7eba998d4b5ef60bd5dd6e22baa217613387863c70a0
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 KB
Contents
module Walruz class NotAuthorized < Exception attr_reader :actor attr_reader :subject attr_reader :action def initialize(actor, subject, action, error_message = nil) @actor = actor @subject = subject @action = action if error_message.nil? super else super(error_message) end end end class AuthorizationActionsNotDefined < Exception end class ActionNotFound < Exception def initialize(failure, params = {}) case failure when :subject_action super("%s class doesn't have an authorization action called :%s nor a :default policy" % [params[:subject].class.name, params[:action]]) when :policy_label super("There is no Policy with the label %s" % params[:label]) end end end base_path = File.dirname(__FILE__) autoload :Actor, base_path + '/walruz/actor' autoload :Subject, base_path + '/walruz/subject' autoload :Policy, base_path + '/walruz/policy' autoload :Utils, base_path + '/walruz/utils' def self.setup config = Config.new yield config end def self.policies Walruz::Policy.policies end class Config def actors=(actors) Array(actors).each do |actor| actor.send(:include, Actor) end end def subjects=(subjects) Array(subjects).each do |subject| subject.send(:include, Subject) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
walruz-0.0.5 | lib/walruz.rb |
walruz-0.0.6 | lib/walruz.rb |