Sha256: 1cb025ffbe7ebf9a39045cbdaa2f555ded20d4434497d70ebb2f612ac930f15e

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

# rails generate effective:datatable NAME [field[:type] field[:type]] [options]

# TODO

# Generates a datatable
# rails generate effective:datatable Thing
# rails generate effective:controller Thing name:string description:text

module Effective
  module Generators
    class DatatableGenerator < Rails::Generators::NamedBase
      include Helpers

      source_root File.expand_path(('../' * 4) + 'lib/scaffolds', __FILE__)

      desc 'Creates an Effective::Datatable in your app/datatables folder.'

      argument :attributes, type: :array, default: [], banner: 'field[:type] field[:type]'

      def assign_attributes
        @attributes = (invoked_attributes.presence || klass_attributes).map do |attribute|
          Rails::Generators::GeneratedAttribute.parse(attribute)
        end

        self.class.send(:attr_reader, :attributes)
      end

      def invoke_datatable
        say_status :invoke, :datatable, :white
      end

      def create_datatable
        template 'datatables/datatable.rb', File.join('app/datatables', namespace_path, "#{plural_name}_datatable.rb")
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
effective_developer-0.0.10 lib/generators/effective/datatable_generator.rb