Class: BaseEditingBootstrap::Generators::HeaderOverrideGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
BaseEditingBootstrap::GeneratorsHelpers
Defined in:
lib/generators/base_editing_bootstrap/header_override/header_override_generator.rb

Constant Summary collapse

TYPES =
%i[base]

Instance Method Summary collapse

Instance Method Details

#copy_form_partialsObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/generators/base_editing_bootstrap/header_override/header_override_generator.rb', line 21

def copy_form_partials
  if attributes.empty?
    say "Need one field"
  else
    base_path = class_to_view_path(name)

    attributes.each do |a|
      attr_name, type = a.split(":")

      type = :base if type.nil?
      type = type.to_sym
      raise "Type #{type} not found in #{TYPES}" unless TYPES.include?(type)
      copy_file "header_field/_#{type}.html.erb", File.join(*base_path, 'header_field', "_#{attr_name}.html.erb")
    end
  end

end