Sha256: 61cdaa0c99d1190921f0f4b927cb353a073ed70dbf31d3d3fd70a0f01d518bf1

Contents?: true

Size: 1021 Bytes

Versions: 6

Compression:

Stored size: 1021 Bytes

Contents

# encoding: utf-8

module MarkMapper
  module Generators
    class ModelGenerator < Rails::Generators::NamedBase
      desc 'Creates a markmapper 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

6 entries across 6 versions & 1 rubygems

Version Path
mark_mapper-0.0.6 lib/rails/generators/mark_mapper/model/model_generator.rb
mark_mapper-0.0.5 lib/rails/generators/mark_mapper/model/model_generator.rb
mark_mapper-0.0.4 lib/rails/generators/mark_mapper/model/model_generator.rb
mark_mapper-0.0.3 lib/rails/generators/mark_mapper/model/model_generator.rb
mark_mapper-0.0.2 lib/rails/generators/mark_mapper/model/model_generator.rb
mark_mapper-0.0.1 lib/rails/generators/mark_mapper/model/model_generator.rb