Sha256: 11294e6380a0234ef8165d47f9d008b111ef7470a78576353907331dae58726a

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

module RailsAssist
  module Orm
    module Base
      def self.included base
        base.class_eval do
          include RailsAssist::Artifact::Model
        end
      end

      protected

      def orm_marker_name name, options = {:model_type => :document}
        document_name options
      end

      def document_name options = {:model_type => :document} 
        type_content = options[:model_type] == :embedded ?  "#{orm_name}::EmbeddedDocument" : "#{orm_name}::Document"
      end

      def clazz name
        "class #{name.to_s.camelize}"
      end

      def file name, include_stmt, &block
        %Q{#{clazz name}
  #{include_stmt}
  #{yield if block}
end}
      end

      def file_w_include name, module_name, &block
        file name, "include #{module_name}", &block 
      end

      def simple_file name, module_name, &block
        %Q{#{clazz name}
  #{yield if block}
end}
      end

      def file_w_inherit name, module_name, &block
        %Q{#{clazz name} < #{module_name}
  #{yield if block}
end}
      end

      def field name, type = nil
        return "#{field_name} :#{name}, #{type}" if type
        "#{field_name} :#{name}"
      end
    end
  end
end

require_all File.dirname(__FILE__) + '/orm'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_artifactor-0.5.1 lib/rails_artifactor/artifact/orm.rb