Sha256: 95fabb94d67f06edbb2a722aa3ac016e386131feca98d6d842d28f2b36ab7201

Contents?: true

Size: 1005 Bytes

Versions: 50

Compression:

Stored size: 1005 Bytes

Contents

module Cmor
  module Core
    module Backend
      module Generators
        class ResourceControllerGenerator < Rails::Generators::Base
          desc 'Generates a singular resource controller with CRUD actions.'

          source_root File.expand_path('../templates', __FILE__)

          class_option :controller_class, type: 'string', aliases: '-c'
          class_option :resource_class, type: 'string', aliases: '-m'

          def generate_controller
            template 'resource_controller.rb', target_filename
          end

          private

          def target_filename
            "app/controllers/#{controller_class.underscore}.rb"
          end

          def controller_class
            @controller_class ||= options[:controller_class]
          end

          def resource_class
            controller_class.chomp('Controller').singularize
          end

          def params_name
            resource_class.demodulize.underscore
          end
        end
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
cmor_core_backend-0.0.38.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.37.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.36.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.35.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.34.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.33.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.32.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.31.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.30.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.29.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.28.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.27.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.26.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.25.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.24.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.22.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.21.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.20.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.19.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb
cmor_core_backend-0.0.18.pre lib/generators/cmor/core/backend/resource_controller/resource_controller_generator.rb