Class: Administrate::Generators::Views::FieldGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Administrate::GeneratorHelpers

#call_generator

Class Method Details

.template_source_pathObject



7
8
9
10
11
12
# File 'lib/generators/administrate/views/field_generator.rb', line 7

def self.template_source_path
  File.expand_path(
    "../../../../../app/views/fields/",
    __FILE__
  )
end

Instance Method Details

#copy_partialsObject



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

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