Sha256: 368d9585c80806a0bb09ef6d872f9c25f47c30204c8fb3f82cad74141ec63662

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 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/effective/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/models/effective/datatables', namespace_path, "#{plural_name}.rb")
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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