Sha256: f672204b596cfd10015a3ec5b73a8f23fa01f0a7646cc03f52517c4a70dfe51f

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 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 :actions, type: :array, default: ['crud'], banner: 'action action'
      class_option :attributes, type: :array, default: [], desc: 'Included permitted params, otherwise read from model'

      def assign_attributes
        @attributes = invoked_attributes.presence || resource_attributes
        self.class.send(:attr_reader, :attributes)
      end

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

      def create_datatable
        unless defined?(EffectiveDatatables)
          say_status(:skipped, :datatable, :yellow) and return
        end

        template 'datatables/datatable.rb', resource.datatable_file
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
effective_developer-0.2.4 lib/generators/effective/datatable_generator.rb
effective_developer-0.2.3 lib/generators/effective/datatable_generator.rb