Class: AdministrateTailwindTheme::Generators::Views::FieldGenerator

Inherits:
ViewGenerator
  • Object
show all
Defined in:
lib/generators/administrate_tailwind_theme/views/field_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.template_source_pathObject



9
10
11
12
13
14
# File 'lib/generators/administrate_tailwind_theme/views/field_generator.rb', line 9

def self.template_source_path
  File.expand_path(
    '../../../../app/views/fields',
    __dir__
  )
end

Instance Method Details

#copy_partialsObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/generators/administrate_tailwind_theme/views/field_generator.rb', line 18

def copy_partials
  resource_path = args.first.try(:underscore)

  if resource_path == 'all'
    entries = Dir.entries(self.class.template_source_path)
    field_types = entries.reject { |name| name[0] == '.' }

    field_types.each do |field_type|
      copy_field_partials(field_type)
    end
  else
    copy_field_partials(resource_path)
  end
end