Sha256: a683fc05aeba3d245aa981b7d21a74dfccaee9a72e192d8ed42c80aaeb03ff7f

Contents?: true

Size: 940 Bytes

Versions: 5

Compression:

Stored size: 940 Bytes

Contents

require 'rails/generators'

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

    desc 'Enjoy::Catalog ItemCategory Model generator'
    def item_category
      template 'item_category.erb', "app/models/#{file_name}.rb"
    end

    private
    def capitalized_class_name
      class_name.capitalize
    end

    def camelcased_class_name
      class_name.camelcase
    end

    def file_name
      underscored_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

5 entries across 5 versions & 1 rubygems

Version Path
enjoy_cms_catalog-0.3.7 lib/generators/enjoy/catalog/models/item_category_generator.rb
enjoy_cms_catalog-0.3.6 lib/generators/enjoy/catalog/models/item_category_generator.rb
enjoy_cms_catalog-0.3.5 lib/generators/enjoy/catalog/models/item_category_generator.rb
enjoy_cms_catalog-0.3.4 lib/generators/enjoy/catalog/models/item_category_generator.rb
enjoy_cms_catalog-0.3.3 lib/generators/enjoy/catalog/models/item_category_generator.rb