Sha256: 69689a9a2d0d9a2a242514c02392001d0cf0ad1fdd37171b715d00c152a0c575

Contents?: true

Size: 519 Bytes

Versions: 31

Compression:

Stored size: 519 Bytes

Contents

# frozen_string_literal: true

module Motor
  class ApiBaseController < ActionController::API
    def current_user
      if defined?(current_admin)
        current_admin
      elsif defined?(current_admin_user)
        current_admin_user
      elsif defined?(super)
        super
      end
    end

    def current_ability
      klass = Class.new
      klass.include(CanCan::Ability)
      klass.define_method(:initialize) do |_user|
        can :manage, :all
      end

      klass.new(current_user)
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
motor-admin-0.1.20 app/controllers/motor/api_base_controller.rb
motor-admin-0.1.18 app/controllers/motor/api_base_controller.rb
motor-admin-0.1.17 app/controllers/motor/api_base_controller.rb
motor-admin-0.1.15 app/controllers/motor/api_base_controller.rb
motor-admin-0.1.16 app/controllers/motor/api_base_controller.rb
motor-admin-0.1.14 app/controllers/motor/api_base_controller.rb
motor-admin-0.1.13 app/controllers/motor/api_base_controller.rb
motor-admin-0.1.12 app/controllers/motor/api_base_controller.rb
motor-admin-0.1.11 app/controllers/motor/api_base_controller.rb
motor-admin-0.1.10 app/controllers/motor/api_base_controller.rb
motor-admin-0.1.9 app/controllers/motor/api_base_controller.rb