Sha256: 48833ccd88fd744d762c008f9ffa467b25735fc9aa0c171b9da011697a53fd9a

Contents?: true

Size: 794 Bytes

Versions: 4

Compression:

Stored size: 794 Bytes

Contents

module Ampere #:nodoc:
  module Generators #:nodoc:
    class ModelGenerator < Rails::Generators::NamedBase #:nodoc:
      source_root File.expand_path("../templates", __FILE__)

      desc "Creates an Ampere model"
      argument :attributes, :type => :array, :default => [], :banner => "field field"

      check_class_collision

      def create_model_file
        template "model.rb.tt", File.join("app/models", class_path, "#{file_name}.rb")
      end

      hook_for :test_framework
    
      unless methods.include?(:module_namespacing)

        # This is only defined on Rails edge at the moment, so include here now
        # as per: https://github.com/mongoid/mongoid/issues/744
        def module_namespacing(&block)
          yield if block
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ampere-1.2.3 lib/rails/generators/ampere/model/model_generator.rb
ampere-1.2.2 lib/rails/generators/ampere/model/model_generator.rb
ampere-1.2.1 lib/rails/generators/ampere/model/model_generator.rb
ampere-1.2.0 lib/rails/generators/ampere/model/model_generator.rb