Sha256: 0793ebbf9b5b00c65b3bacbc53b44c30acd10c0c9334b4cdf897ca3e549516f3

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

module Olivander
  class ScaffoldGenerator < Rails::Generators::NamedBase
    include Rails::Generators::ResourceHelpers

    argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"

    source_root File.expand_path('templates/scaffold', __dir__)

    hook_for :orm, as: :model, required: true do |instance, controller|
      instance.invoke controller, [ instance.name ], instance.options.merge({ test_framework: false })
    end

    hook_for :datatable, as: :boolean, default: true

    hook_for :resource_controller do |instance, controller|
      instance.invoke controller, [ instance.name.pluralize ], instance.options.merge({ helper: false, test_framework: false, assets: false })
    end

    def create_views
      # template "views/_form.html.haml", File.join("app/views", controller_file_path, '_form.html.haml')
      # template "views/_model.html.haml", File.join("app/views", controller_file_path, "_#{file_name}.html.haml")
    end

    hook_for :resource_route, in: :rails
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
five-two-nw-olivander-0.1.2.43.a lib/generators/olivander/scaffold_generator.rb