Sha256: 2d8ccfc15528b4cbc5d21b3e56fbe522b1598dff068ed902bedaf1aa17cd973a

Contents?: true

Size: 693 Bytes

Versions: 9

Compression:

Stored size: 693 Bytes

Contents

require 'generators/active_record_schema'

module ActiveRecordSchema
  module Generators
    class ModelGenerator < Base
      class_option :in, :type => :string
      class_option :inherit, :type => :string, :default => 'ActiveRecord::Base'
      class_option :from

      def create_model_file
        create_file ["app", "models", subdir, "#{file_name}.rb"].compact.join('/'), <<-FILE
    class #{class_name} < #{ inherit }
    end
        FILE
      end
  
      private

      def subdir
        in_opt = "#{options[:in]}".strip
        in_opt.empty? || in_opt.match(/\//) ? nil : in_opt
      end
  
      def inherit
        options[:inherit]
      end
      
      
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
active_record_schema-0.3.5 lib/generators/active_record_schema/model/model_generator.rb
active_record_schema-0.3.4 lib/generators/active_record_schema/model/model_generator.rb
active_record_schema-0.3.3 lib/generators/active_record_schema/model/model_generator.rb
active_record_schema-0.3.2 lib/generators/active_record_schema/model/model_generator.rb
active_record_schema-0.2.5 lib/generators/active_record_schema/model/model_generator.rb
active_record_schema-0.2.4 lib/generators/active_record_schema/model/model_generator.rb
active_record_schema-0.2.2 lib/generators/active_record_schema/model/model_generator.rb
active_record_schema-0.2.1 lib/generators/active_record_schema/model/model_generator.rb
active_record_schema-0.2.0 lib/generators/active_record_schema/model/model_generator.rb