Module: Ixtlan::Guard::ActionController::InstanceMethods
- Defined in:
- lib/ixtlan/guard/guard_rails.rb
Overview
:nodoc:
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/ixtlan/guard/guard_rails.rb', line 91 def self.included(base) base.class_eval do def self.guard_filter(*args, &block) method = nil#"_intern_#{guard_filters.size}" = {} case args.size when 1 if args[0].is_a? Symbol method = args[0] else = args[0] end when 2 method = args[0].to_sym = args[1] else raise "argument error, expected (Symbol, Hash) or (Symbol) or (Hash)" end guard_filters << Filter.new(method, , &block) end def self.guard_filters @_guard_filters ||= [] end def self.guard ::Rails.application.config.guard end def self.allowed?(action, current_groups, reference = nil) filter = guard_filters.detect do |f| f.allowed?(action) end if filter guard.check(self.controller_name, action, current_groups || []) do |groups| filter.proc(self, reference).call(groups) end else # TODO maybe do something with the reference guard.check(controller_name, action, current_groups || []) end end end end |