Sha256: a9e88d92864c994ae5ff06b3ab8ac1f5ebf7329140e8c70789cfa01d667d1381

Contents?: true

Size: 744 Bytes

Versions: 3

Compression:

Stored size: 744 Bytes

Contents

require 'rails/generators/erb'
require 'rails/generators/resource_helpers'

class Rails::HamlModalCrudGenerator < Rails::Generators::NamedBase
  include Rails::Generators::ResourceHelpers
  argument :attributes, type: :array, default: [], banner: 'field:type field:type'
  source_root File.expand_path('../templates', __FILE__)

  def copy_view_files
    available_actions.each do |view|
      template "#{view}.js.erb", File.join('app/views', controller_file_path, "#{view}.js.erb")
    end
    run_haml
  end

  protected

  def available_actions
    %w(create update destroy)
  end

  def handler
    :erb
  end

  def run_haml
    attrs = attributes.collect {|a| "#{a.name}:#{a.type}" }
    generate 'haml:scaffold', name, *attrs
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bootbox_crud-0.2.1 lib/generators/rails/haml_modal_crud/haml_modal_crud_generator.rb
bootbox_crud-0.2.0 lib/generators/rails/haml_modal_crud/haml_modal_crud_generator.rb
bootbox_crud-0.1.1.7 lib/generators/rails/haml_modal_crud/haml_modal_crud_generator.rb