Sha256: a8c171e022d5af823ae2a90838235579e3a8eafd072ed303708a8917abebd8e6

Contents?: true

Size: 1023 Bytes

Versions: 4

Compression:

Stored size: 1023 Bytes

Contents

# encoding: utf-8

module MongoMapper
  module Generators
    class ModelGenerator < Rails::Generators::NamedBase
      desc 'Creates a mongomapper model'

      argument :name, :type => :string
      argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"

      check_class_collision

      class_option :timestamps, :type => :boolean
      class_option :parent,     :type => :string, :desc => "The parent class for the generated model"

      def self.source_root
        @source_root ||= File.expand_path("../templates", __FILE__)
      end

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

      hook_for :test_framework

      protected

        def parent_class_name
          options[:parent]
        end

        # Rails 3.0.X compatibility
        unless methods.include?(:module_namespacing)
          def module_namespacing(&block)
            yield if block
          end
        end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongo_mapper-0.13.1 lib/rails/generators/mongo_mapper/model/model_generator.rb
mongo_mapper-0.13.0 lib/rails/generators/mongo_mapper/model/model_generator.rb
mongo_mapper-0.13.0.beta2 lib/rails/generators/mongo_mapper/model/model_generator.rb
mongo_mapper-0.13.0.beta1 lib/rails/generators/mongo_mapper/model/model_generator.rb