Class: Arrthorizer::Rails::ControllerAction

Inherits:
Object
  • Object
show all
Defined in:
lib/arrthorizer/rails/controller_action.rb

Constant Summary collapse

ControllerNotDefined =
Class.new(Arrthorizer::ArrthorizerException)
ActionNotDefined =
Class.new(Arrthorizer::ArrthorizerException)
ActionNotConfigured =
Class.new(Arrthorizer::ArrthorizerException)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ ControllerAction

Returns a new instance of ControllerAction.



15
16
17
18
19
20
# File 'lib/arrthorizer/rails/controller_action.rb', line 15

def initialize(attrs)
  self.controller_path = attrs.fetch(:controller) { raise ControllerNotDefined }
  self.action_name = attrs.fetch(:action) { raise ActionNotDefined }

  self.class.register(self)
end

Instance Attribute Details

#action_nameObject

Returns the value of attribute action_name.



9
10
11
# File 'lib/arrthorizer/rails/controller_action.rb', line 9

def action_name
  @action_name
end

#controller_pathObject

Returns the value of attribute controller_path.



9
10
11
# File 'lib/arrthorizer/rails/controller_action.rb', line 9

def controller_path
  @controller_path
end

#privilegeObject

Returns the value of attribute privilege.



8
9
10
# File 'lib/arrthorizer/rails/controller_action.rb', line 8

def privilege
  @privilege
end

Class Method Details

.get_current(controller) ⇒ Object



11
12
13
# File 'lib/arrthorizer/rails/controller_action.rb', line 11

def self.get_current(controller)
  fetch(key_for(controller))
end

Instance Method Details

#to_keyObject



22
23
24
# File 'lib/arrthorizer/rails/controller_action.rb', line 22

def to_key
  "#{controller_path}##{action_name}"
end