Sha256: ab0669649e12f249532a5bc385e1da58b28d3d97a06660228db53e2645ff98bc
Contents?: true
Size: 1.07 KB
Versions: 4
Compression:
Stored size: 1.07 KB
Contents
module Arrthorizer module Rails class ControllerAction ControllerNotDefined = Class.new(Arrthorizer::ArrthorizerException) ActionNotDefined = Class.new(Arrthorizer::ArrthorizerException) attr_accessor :privilege attr_reader :controller_path, :action_name def self.get_current(controller) fetch(key_for(controller)) end def initialize(attrs) self.controller_path = attrs.fetch(:controller) { raise ControllerNotDefined } self.action_name = attrs.fetch(:action) { raise ActionNotDefined } self.class.register(self) end def to_key "#{controller_path}##{action_name}" end private attr_writer :controller_path, :action_name def self.key_for(controller) "#{controller.controller_path}##{controller.action_name}" end def self.fetch(key) registry.fetch(key) end def self.register(controller_action) registry.add(controller_action) end def self.registry @registry ||= Registry.new end end end end
Version data entries
4 entries across 4 versions & 1 rubygems