Module: Fortress::Mechanism
- Defined in:
- lib/fortress/mechanism.rb
Overview
Mechanism embbed all the logic of the Fortress library.
Class Method Summary collapse
- .append_or_update(controller_name, key, value) ⇒ Object
- .authorise!(class_name, actions) ⇒ Object
- .initialize_authorisations ⇒ Object
- .parse_options(controller, actions, options) ⇒ Object
Class Method Details
.append_or_update(controller_name, key, value) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/fortress/mechanism.rb', line 68 def self.append_or_update(controller_name, key, value) [controller_name] ||= {} if [controller_name].key?(key) (controller_name, key, value) else (controller_name, key, value) end end |
.authorise!(class_name, actions) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/fortress/mechanism.rb', line 78 def self.(class_name, actions) if actions == :all append_or_update(class_name, :all, true) return end append_or_update(class_name, :only, Array(actions)) end |
.initialize_authorisations ⇒ Object
53 54 55 |
# File 'lib/fortress/mechanism.rb', line 53 def self. self. = {} end |
.parse_options(controller, actions, options) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/fortress/mechanism.rb', line 57 def self.(controller, actions, ) .each do |key, value| case key when :if Mechanism.(controller.name, value, actions) when :except Mechanism.(controller.name, value) end end end |