Sha256: 9f84fb81783d0781fbcbb8f4cd77909ef8f82e0ac536ae2070d83c452ddcde50
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
module Walruz class NotAuthorized < Exception 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.3 | lib/walruz.rb |
walruz-0.0.4 | lib/walruz.rb |