Class: Hancock::Catalog::Views::ForGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/hancock/catalog/views/for_generator.rb

Instance Method Summary collapse

Instance Method Details

#forObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/generators/hancock/catalog/views/for_generator.rb', line 10

def for
  (views_args == ['all'] ? permitted_file_views : ((views_args & permitted_path_views).map { |v| permitted_file_views(v) }.flatten)).each do |v|
    if v.index('items')
      res_v = "#{underscored_pluralized_class_name}/#{v.gsub(/.*\//, "")}"
    else
      res_v = "#{underscored_singularized_class_name}_categories/#{v.gsub(/.*\//, "")}"
    end
    copy_file "#{v}.html.slim", "app/views/#{res_v}.html.slim"
  end
end