Class: Effective::Generators::DatatableGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Helpers
Defined in:
lib/generators/effective/datatable_generator.rb

Instance Method Summary collapse

Instance Method Details

#assign_attributesObject



25
26
27
28
# File 'lib/generators/effective/datatable_generator.rb', line 25

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

#create_datatableObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/generators/effective/datatable_generator.rb', line 34

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

#invoke_datatableObject



30
31
32
# File 'lib/generators/effective/datatable_generator.rb', line 30

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

#validate_resourceObject



21
22
23
# File 'lib/generators/effective/datatable_generator.rb', line 21

def validate_resource
  exit unless resource_valid?
end