Sha256: ea46fd1e55f5aa24ddb0dee2134cb8aa292ec3b1005487792fb8c24ea65f9414

Contents?: true

Size: 1.62 KB

Versions: 18

Compression:

Stored size: 1.62 KB

Contents

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

# TODO

# Generates a datatable
# rails generate effective:datatable Thing
# rails generate effective:datatable 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 validate_resource
        exit unless resource_valid?
      end

      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

        with_resource_tenant do
          if admin_effective_scaffold?
            template "#{scaffold_path}/datatables/datatable.rb", resource.admin_effective_datatable_file
          elsif effective_scaffold?
            template "#{scaffold_path}/datatables/datatable.rb", resource.effective_datatable_file
          else
            template "#{scaffold_path}/datatables/datatable.rb", resource.datatable_file
          end

        end

      end

    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
effective_developer-0.8.5 lib/generators/effective/datatable_generator.rb
effective_developer-0.8.4 lib/generators/effective/datatable_generator.rb
effective_developer-0.8.3 lib/generators/effective/datatable_generator.rb
effective_developer-0.8.2 lib/generators/effective/datatable_generator.rb
effective_developer-0.8.1 lib/generators/effective/datatable_generator.rb
effective_developer-0.8.0 lib/generators/effective/datatable_generator.rb
effective_developer-0.7.8 lib/generators/effective/datatable_generator.rb
effective_developer-0.7.7 lib/generators/effective/datatable_generator.rb
effective_developer-0.7.6 lib/generators/effective/datatable_generator.rb
effective_developer-0.7.5 lib/generators/effective/datatable_generator.rb
effective_developer-0.7.4 lib/generators/effective/datatable_generator.rb
effective_developer-0.7.3 lib/generators/effective/datatable_generator.rb
effective_developer-0.7.2 lib/generators/effective/datatable_generator.rb
effective_developer-0.7.1 lib/generators/effective/datatable_generator.rb
effective_developer-0.7.0 lib/generators/effective/datatable_generator.rb
effective_developer-0.6.17 lib/generators/effective/datatable_generator.rb
effective_developer-0.6.16 lib/generators/effective/datatable_generator.rb
effective_developer-0.6.15 lib/generators/effective/datatable_generator.rb