Sha256: 93e318eded465105d43237057274138f45adb934f3ad5d7220bfa5e3e6a36f87

Contents?: true

Size: 1012 Bytes

Versions: 45

Compression:

Stored size: 1012 Bytes

Contents

require 'rails/generators'
require 'rails/generators/named_base'

module Curly
  module Generators
    class ControllerGenerator < Rails::Generators::NamedBase
      source_root File.expand_path("../templates", __FILE__)

      argument :actions, type: :array, default: [], banner: "action action"

      def create_view_files
        base_views_path = File.join("app/views", class_path, file_name)
        base_presenters_path = File.join("app/presenters", class_path, file_name)

        empty_directory base_views_path
        empty_directory base_presenters_path

        actions.each do |action|
          @view_path = File.join(base_views_path, "#{action}.html.curly")
          @presenter_path = File.join(base_presenters_path, "#{action}_presenter.rb")
          @action = action
          @presenter_name = "#{class_name}::#{action.capitalize}Presenter"

          template "view.html.curly.erb", @view_path
          template "presenter.rb.erb", @presenter_path
        end
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
curly-templates-3.4.0 lib/generators/curly/controller/controller_generator.rb
curly-templates-3.3.0 lib/generators/curly/controller/controller_generator.rb
curly-templates-3.2.0 lib/generators/curly/controller/controller_generator.rb
curly-templates-3.1.0 lib/generators/curly/controller/controller_generator.rb
curly-templates-3.0.0 lib/generators/curly/controller/controller_generator.rb
curly-templates-2.6.5 lib/generators/curly/controller/controller_generator.rb
curly-templates-2.6.4 lib/generators/curly/controller/controller_generator.rb
curly-templates-2.6.3 lib/generators/curly/controller/controller_generator.rb
curly-templates-2.6.2 lib/generators/curly/controller/controller_generator.rb
curly-templates-2.6.1 lib/generators/curly/controller/controller_generator.rb
curly-templates-2.6.0 lib/generators/curly/controller/controller_generator.rb
curly-templates-2.5.0 lib/generators/curly/controller/controller_generator.rb
curly-templates-2.4.1 lib/generators/curly/controller/controller_generator.rb
curly-templates-2.4.0 lib/generators/curly/controller/controller_generator.rb
curly-templates-2.3.2 lib/generators/curly/controller/controller_generator.rb
curly-templates-2.3.1 lib/generators/curly/controller/controller_generator.rb
curly-templates-2.3.0 lib/generators/curly/controller/controller_generator.rb
curly-templates-2.2.0 lib/generators/curly/controller/controller_generator.rb
curly-templates-2.1.1 lib/generators/curly/controller/controller_generator.rb
curly-templates-2.1.0 lib/generators/curly/controller/controller_generator.rb