class Regulator::ActiveAdminAdapter
Public Instance Methods
format_action(action, subject)
click to toggle source
# File lib/regulator/active_admin_adapter.rb, line 23 def format_action(action, subject) # https://github.com/elabs/regulator/blob/master/lib/generators/regulator/install/templates/application_policy.rb case action when ActiveAdmin::Auth::CREATE then :create? when ActiveAdmin::Auth::UPDATE then :update? when ActiveAdmin::Auth::READ then subject.is_a?(Class) ? :index? : :show? when ActiveAdmin::Auth::DESTROY then subject.is_a?(Class) ? :destroy_all? : :destroy? else "#{action}?" end end
retrieve_policy(subject)
click to toggle source
# File lib/regulator/active_admin_adapter.rb, line 15 def retrieve_policy(subject) case subject when nil then Regulator.policy!(user, resource, self.resource.controller) when Class then Regulator.policy!(user, subject.new, self.resource.controller) else Regulator.policy!(user, subject, self.resource.controller) end end
scope_collection(collection, action = Auth::READ)
click to toggle source
# File lib/regulator/active_admin_adapter.rb, line 9 def scope_collection(collection, action = Auth::READ) # scoping is appliable only to read/index action # which means there is no way how to scope other actions Regulator.policy_scope!(user, collection, self.resource.controller) end