Sha256: c855e0a5dfbf7bf893c5472d51a88ae22d83a840a96c7cc18f2f84435d58bd49

Contents?: true

Size: 857 Bytes

Versions: 8

Compression:

Stored size: 857 Bytes

Contents

require 'rails/generators'
require File.expand_path('../utils', __FILE__)

module Hancock::Cms
  class ModelGenerator < Rails::Generators::Base
    source_root File.expand_path('../templates', __FILE__)
    argument :class_name_arg, type: :string, default: ""

    desc 'Hancock::CMS Model generator'
    def install
      template 'model.erb', "app/models/#{file_name}.rb"
    end

    private
    def class_name
      class_name_arg.blank? ? "SetClassForModel" : class_name_arg
    end

    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
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hancock_cms-1.0.1 lib/generators/hancock/cms/model_generator.rb
hancock_cms-2.0.0.2 lib/generators/hancock/cms/model_generator.rb
hancock_cms-1.0.0.4 lib/generators/hancock/cms/model_generator.rb
hancock_cms-1.0.0.3 lib/generators/hancock/cms/model_generator.rb
hancock_cms-2.0.0.1 lib/generators/hancock/cms/model_generator.rb
hancock_cms-1.0.0.2 lib/generators/hancock/cms/model_generator.rb
hancock_cms-2.0.0 lib/generators/hancock/cms/model_generator.rb
hancock_cms-1.0.0 lib/generators/hancock/cms/model_generator.rb