class Arpa::ResourcesController

Public Instance Methods

generate_resources_and_actions() click to toggle source

GET /generate_resources_and_actions

# File lib/generators/arpa/templates/controllers/resources_controller.rb, line 14
def generate_resources_and_actions
  Rails.application.eager_load!

  resource_params = {
    resourceables: ApplicationController.descendants,
    except_action_methods: ApplicationController.action_methods
  }
  resource_creator.create(resource_params,
                          success: success_callback,
                          fail: fail_callback)

  redirect_to resources_path
end
index() click to toggle source

GET /resources

# File lib/generators/arpa/templates/controllers/resources_controller.rb, line 6
def index
  @resources = resource_finder.all
end
show() click to toggle source

GET /resources/1

# File lib/generators/arpa/templates/controllers/resources_controller.rb, line 11
def show; end

Private Instance Methods

fail_callback() click to toggle source
# File lib/generators/arpa/templates/controllers/resources_controller.rb, line 36
def fail_callback
  lambda do |_error|
    flash[:alert] = I18n.t('flash.actions.generate_resources_and_actions.alert')
  end
end
resource_creator() click to toggle source
# File lib/generators/arpa/templates/controllers/resources_controller.rb, line 42
def resource_creator
  @resource_creator ||= Arpa::Services::Resources::ResourceManagerCreator.new
end
resource_finder() click to toggle source
# File lib/generators/arpa/templates/controllers/resources_controller.rb, line 46
def resource_finder
  @resource_finder ||= Arpa::Repositories::Resources::Finder.new
end
set_resource() click to toggle source
# File lib/generators/arpa/templates/controllers/resources_controller.rb, line 50
def set_resource
  @resource = resource_finder.find(params[:id])
end
success_callback() click to toggle source
# File lib/generators/arpa/templates/controllers/resources_controller.rb, line 30
def success_callback
  lambda do |_resource|
    flash[:notice] = I18n.t('flash.actions.generate_resources_and_actions.notice')
  end
end