Sha256: 46f9e73f1be8340ddcd6cefd2a6c6c11821122e4b2d9ace206905cee4e3c8909

Contents?: true

Size: 925 Bytes

Versions: 5

Compression:

Stored size: 925 Bytes

Contents

require 'rails/generators'

module Enjoy::Catalog::Models
  class ItemImageGenerator < 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 ItemImage Model generator'
    def item_image
      template 'item_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 item_class_name
      item_class_name_arg.blank? ? camelcased_class_name.sub(/Image$/, "") : 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_image_generator.rb
enjoy_cms_catalog-0.3.6 lib/generators/enjoy/catalog/models/item_image_generator.rb
enjoy_cms_catalog-0.3.5 lib/generators/enjoy/catalog/models/item_image_generator.rb
enjoy_cms_catalog-0.3.4 lib/generators/enjoy/catalog/models/item_image_generator.rb
enjoy_cms_catalog-0.3.3 lib/generators/enjoy/catalog/models/item_image_generator.rb