Sha256: 945af855f769fe1dd19dcbff253b4c5986ef0d1e92cf792484add95cf3df9079

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 KB

Contents

require 'rails/generators'

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

    desc 'Enjoy::Catalog CategoryImage Model generator'
    def category_image
      template 'category_image.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 camelcased_category_class_name
      category_class_name.camelcase
    end

    def category_class_name
      category_class_name_arg.blank? ? camelcased_class_name.sub(/Image$/i, "") : category_class_name_arg
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
enjoy_cms_catalog-0.4.1 lib/generators/enjoy/catalog/models/category_image_generator.rb
enjoy_cms_catalog-0.4.0.6 lib/generators/enjoy/catalog/models/category_image_generator.rb
enjoy_cms_catalog-0.4.0.5 lib/generators/enjoy/catalog/models/category_image_generator.rb
enjoy_cms_catalog-0.4.0.4 lib/generators/enjoy/catalog/models/category_image_generator.rb
enjoy_cms_catalog-0.4.0.3 lib/generators/enjoy/catalog/models/category_image_generator.rb
enjoy_cms_catalog-0.4.0.2 lib/generators/enjoy/catalog/models/category_image_generator.rb
enjoy_cms_catalog-0.4.0.1 lib/generators/enjoy/catalog/models/category_image_generator.rb
enjoy_cms_catalog-0.4.0 lib/generators/enjoy/catalog/models/category_image_generator.rb
enjoy_cms_catalog-0.4.0.beta3 lib/generators/enjoy/catalog/models/category_image_generator.rb