Sha256: 79588eb34b213fddc2fdbcd97b6a0ef07696e457e38e385b65406868373da6e6

Contents?: true

Size: 985 Bytes

Versions: 4

Compression:

Stored size: 985 Bytes

Contents

# encoding: utf-8
require "rails/generators/mongoid_generator"
require 'generators/my_scaffold_generator'

module MyGenerators #:nodoc:
  module Generators #:nodoc:
    class ModelGenerator < Mongoid::Generators::Base #:nodoc:
      include MyGenerators::Generators::MyScaffoldGenerator
      desc "Creates a Mongoid model"
      argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"

      class_option :timestamps, :type => :boolean
      class_option :parent,     :type => :string, :desc => "The parent class for the generated model"
      class_option :versioning, :type => :boolean, :default => false, :desc => "Enable mongoid versioning"

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

      hook_for :test_framework
      
      def self.source_root
        @source_root ||= File.expand_path("templates", File.dirname(__FILE__))
      end
        
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
my_generators-0.0.4 lib/generators/my_generators/model/model_generator.rb
my_generators-0.0.3 lib/generators/my_generators/model/model_generator.rb
my_generators-0.0.2 lib/generators/my_generators/model/model_generator.rb
my_generators-0.0.1 lib/generators/my_generators/model/model_generator.rb