Sha256: eb71100f0034a5ca70d5e3b99cc5beebfdb7118930a5aa3dfba1b2b7436e17ce

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

module Gummi
  module RepositoryLayer
    module Repository
      extend ActiveSupport::Concern

      included do
        include Repobahn::Repository
        after_conversion :set_id_and_version
      end

      def get(id)
        document = db_class.get id
        db_instance_to_entity document if document
      end

      def search(options = {}, &block)
        search = db_class.new_filtered_search(options)
        yield search if block_given?
        Repository::Result.new search.execute, self
      end

      def raw_search(options = {}, &block)
        search = db_class.new_raw_search(options)
        yield search if block_given?
        Repository::Result.new search.execute, self
      end

      def overwrite(entity)
        return false unless entity.valid?
        document = db_class.new(entity.attributes)
        document.overwrite
      end

      def set_id_and_version(entity, db_instance)
        entity.id      = db_instance.id
        entity.version = db_instance.version
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gummi-0.3.4 lib/gummi/repository_layer/repository.rb
gummi-0.3.3 lib/gummi/repository_layer/repository.rb
gummi-0.3.2 lib/gummi/repository_layer/repository.rb
gummi-0.3.1 lib/gummi/repository_layer/repository.rb
gummi-0.3.0 lib/gummi/repository_layer/repository.rb