Class: Effective::Generators::DatatableGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Effective::Generators::DatatableGenerator
- Includes:
- Helpers
- Defined in:
- lib/generators/effective/datatable_generator.rb
Instance Method Summary collapse
- #assign_attributes ⇒ Object
- #create_datatable ⇒ Object
- #invoke_datatable ⇒ Object
- #validate_resource ⇒ Object
Instance Method Details
#assign_attributes ⇒ Object
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_datatable ⇒ Object
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_datatable ⇒ Object
30 31 32 |
# File 'lib/generators/effective/datatable_generator.rb', line 30 def invoke_datatable say_status :invoke, :datatable, :white end |
#validate_resource ⇒ Object
21 22 23 |
# File 'lib/generators/effective/datatable_generator.rb', line 21 def validate_resource exit unless resource_valid? end |