Class: Api::BaseController

Inherits:
ActionController::Base
  • Object
show all
Includes:
Foreman::ThreadSession::Cleaner
Defined in:
app/controllers/api/base_controller.rb

Overview

TODO: inherit from application controller after cleanup

Direct Known Subclasses

V1::BaseController, V2::BaseController

Instance Method Summary collapse

Methods included from Foreman::ThreadSession::Cleaner

#clear_thread, included

Instance Method Details

#get_resourceObject


26
27
28
# File 'app/controllers/api/base_controller.rb', line 26

def get_resource
  instance_variable_get :"@#{resource_name}" or raise 'no resource loaded'
end

#resource_classObject


34
35
36
# File 'app/controllers/api/base_controller.rb', line 34

def resource_class
  @resource_class ||= resource_name.camelize.constantize
end

#resource_nameObject


30
31
32
# File 'app/controllers/api/base_controller.rb', line 30

def resource_name
  controller_name.singularize
end

#resource_scopeObject


38
39
40
# File 'app/controllers/api/base_controller.rb', line 38

def resource_scope
  @resource_scope ||= resource_class.scoped
end