Sha256: e22df9f2e2f98f7bc186e68eb62881d1441853ead08aace69e68b19856cc7a19

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

module Arpa
  class ResourcesController < ApplicationController
    before_action :set_resource, only: [:show]

    # GET /resources
    def index
      @resources = resource_finder.all
    end

    # GET /resources/1
    def show
    end

    # GET /generate_resources_and_actions
    def generate_resources_and_actions
      Rails.application.eager_load!

      resource_creator.create({resourceables: ApplicationController.descendants, except_action_methods: ApplicationController.action_methods}, {
        success: -> (resource) {
          flash[:notice] = I18n.t('flash.actions.generate_resources_and_actions.notice')
        },
        fail: -> (error) {
          flash[:alert] = I18n.t('flash.actions.generate_resources_and_actions.alert')
        }
      })

      redirect_to resources_path
    end

    private

    def resource_creator
      @resource_creator ||= Arpa::Services::Resources::ResourceManagerCreator.new
    end

    def resource_finder
      @resource_finder ||= Arpa::Repositories::Resources::Finder.new
    end

    def set_resource
      @resource = resource_finder.find(params[:id])
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
arpa-0.2.0 lib/generators/arpa/templates/controllers/resources_controller.rb
arpa-0.1.0 lib/generators/arpa/templates/controllers/resources_controller.rb
arpa-0.0.9 lib/generators/arpa/templates/controllers/resources_controller.rb
arpa-0.0.8 lib/generators/arpa/templates/controllers/resources_controller.rb
arpa-0.0.7 lib/generators/arpa/templates/controllers/resources_controller.rb