Sha256: d5ac5114ae2de16c61fd790450f0438d7a8fe82fdb7cc2dee7912ea7399772b8

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require 'rails/generators'

module Hancock::Catalog::Controllers
  class CategoryGenerator < Rails::Generators::Base
    source_root File.expand_path('../templates', __FILE__)
    argument :class_name, type: :string
    argument :item_class_name_arg, type: :string, default: ""

    desc 'Hancock::Catalog Category Controller generator'
    def category
      template 'categories_controller.erb', "app/controllers/#{file_name}_controller.rb"
    end

    private
    def capitalized_class_name
      class_name.capitalize
    end

    def camelcased_class_name
      class_name.camelcase
    end

    def camelcased_pluralized_class_name
      camelcased_class_name.pluralize
    end

    def file_name
      underscored_pluralized_class_name
    end

    def underscored_class_name
      camelcased_class_name.underscore
    end

    def underscored_pluralized_class_name
      underscored_class_name.pluralize
    end

    def item_class_name
      item_class_name_arg.blank? ? camelcased_class_name.sub(/Category$/, "") : item_class_name_arg
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hancock_cms_catalog-1.0.2 lib/generators/hancock/catalog/controllers/category_generator.rb