lib/generators/spud/cms/layout_generator.rb in tb_cms-1.2.3 vs lib/generators/spud/cms/layout_generator.rb in tb_cms-1.3.beta1

- old
+ new

@@ -1,34 +1,34 @@ require 'rails/generators/migration' class Spud::Cms::LayoutGenerator < ::Rails::Generators::Base - desc "This generator creates a new spud cms layout file" - argument :template_name, :type => :string - argument :attributes, :type => :array, :default => [], :banner => "content_block content_block" + desc 'This generator creates a new spud cms layout file' + argument :template_name, type: :string + argument :attributes, type: :array, default: [], banner: 'content_block content_block' source_root File.expand_path('../templates', __FILE__) def create_layout - template "layout.html.erb", "app/views/layouts/#{template_name.downcase.underscore}.html.erb" + template 'layout.html.erb', "app/views/layouts/#{template_name.downcase.underscore}.html.erb" end def create_layout_action concern_path = 'app/controllers/concerns/spud_cms_layout_actions.rb' - if !File.exist?(File.join(Rails.root, concern_path)) + unless File.exist?(File.join(Rails.root, concern_path)) template 'layout_actions.rb', 'app/controllers/concerns/spud_cms_layout_actions.rb' end - inject_into_file concern_path, :after => "extend ActiveSupport::Concern\n" do <<-HEREDOC + inject_into_file concern_path, after: "extend ActiveSupport::Concern\n" do + <<-HEREDOC def #{template_name.downcase.underscore}_action(method) # this action is called when the #{template_name} cms layout is used end HEREDOC end end -private + private def concern_content - end end