Sha256: 2bc47a27eebf8607eadd649daa91f8e2b6ad699609afe5c76e25b146abd54fbc

Contents?: true

Size: 1.18 KB

Versions: 34

Compression:

Stored size: 1.18 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(all: true)
        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

34 entries across 34 versions & 1 rubygems

Version Path
effective_developer-0.5.5 lib/generators/effective/datatable_generator.rb
effective_developer-0.5.4 lib/generators/effective/datatable_generator.rb
effective_developer-0.5.3 lib/generators/effective/datatable_generator.rb
effective_developer-0.5.2 lib/generators/effective/datatable_generator.rb
effective_developer-0.5.1 lib/generators/effective/datatable_generator.rb
effective_developer-0.5.0 lib/generators/effective/datatable_generator.rb
effective_developer-0.4.16 lib/generators/effective/datatable_generator.rb
effective_developer-0.4.15 lib/generators/effective/datatable_generator.rb
effective_developer-0.4.14 lib/generators/effective/datatable_generator.rb
effective_developer-0.4.13 lib/generators/effective/datatable_generator.rb
effective_developer-0.4.12 lib/generators/effective/datatable_generator.rb
effective_developer-0.4.11 lib/generators/effective/datatable_generator.rb
effective_developer-0.4.10 lib/generators/effective/datatable_generator.rb
effective_developer-0.4.9 lib/generators/effective/datatable_generator.rb
effective_developer-0.4.8 lib/generators/effective/datatable_generator.rb
effective_developer-0.4.7 lib/generators/effective/datatable_generator.rb
effective_developer-0.4.6 lib/generators/effective/datatable_generator.rb
effective_developer-0.4.5 lib/generators/effective/datatable_generator.rb
effective_developer-0.4.4 lib/generators/effective/datatable_generator.rb
effective_developer-0.4.3 lib/generators/effective/datatable_generator.rb