Sha256: 40eebdf6efe6174b81c50a72ca574bf86ac326affdb0171595abadc2a0387aea

Contents?: true

Size: 625 Bytes

Versions: 4

Compression:

Stored size: 625 Bytes

Contents

module Para
  module Page
    class SectionGenerator < Rails::Generators::NamedBase
      include Para::Generators::NameHelpers

      source_root File.expand_path("../templates", __FILE__)

      argument :attributes, type: :array

      def generate_form
        template(
          "section.rb.erb",
          "app/models/page_section/#{ plural_namespaced_path }.rb"
        )
      end

      private

      def attributes_separated_with_commas
        if attributes.empty?
          ':title'
        else
          attributes.map { |attribute| ":#{ attribute.name }" }.join(', ')
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
para-0.6.3 lib/generators/para/page/section/section_generator.rb
para-0.6.2 lib/generators/para/page/section/section_generator.rb
para-0.5.4 lib/generators/para/page/section/section_generator.rb
para-0.5.3 lib/generators/para/page/section/section_generator.rb