Sha256: 12e5cefb96f7fd8e64e0c6f389e08a370b2336a6808f99efe50e2727cb61b8e6

Contents?: true

Size: 827 Bytes

Versions: 3

Compression:

Stored size: 827 Bytes

Contents

motion_require 'extensions'
motion_require 'db'

module Yapper::Document
  motion_require 'document/callbacks'
  motion_require 'document/persistence'
  motion_require 'document/relation'
  motion_require 'document/selection'

  extend MotionSupport::Concern

  include Persistence
  include Selection
  include Callbacks
  include Relation

  included do
    field :id, :type => String
    index(:id)
  end

  module ClassMethods
    def db
      Yapper::DB.instance
    end

    def _type
      self.to_s
    end

    def model_name
      self.to_s.downcase
    end
  end

  def _type
    self.class._type
  end

  def db
    self.class.db
  end

  def model_name
    self.class.model_name
  end

  # TODO Add specs
  def ==(other)
    self.id == other.try(:id)
  end
  alias :eql? :==

  def hash
    self.id.hash
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
motion-yapper-0.1.0 lib/yapper/document.rb
motion-yapper-0.0.3 lib/yapper/document.rb
motion-yapper-0.0.2 lib/yapper/document.rb