Module: Ixtlan::Guard::Allowed::InstanceMethods

Defined in:
lib/ixtlan/guard/guard_rails.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#allowed?(resource, action, reference = nil) ⇒ Boolean

Returns:

  • (Boolean)


203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/ixtlan/guard/guard_rails.rb', line 203

def allowed?(resource, action, reference = nil)
  if resource.to_s != controller.class.controller_name || reference
    other = "#{resource}Controller".classify.constantize
    if other.respond_to?(:allowed?)
      if reference
        other.send(:allowed?, action, controller.current_groups, reference)
      else
        other.send(:allowed?, action, controller.current_groups)
      end
    else
      raise "can not find 'allowed?' on #{other}"
    end
  else
    controller.send(:allowed?, action, resource)
  end
end