Sha256: c3d6214f1567b6ab2d693ef2623d89cde76281e1c88bcb5311075546ff5b40fe

Contents?: true

Size: 845 Bytes

Versions: 6

Compression:

Stored size: 845 Bytes

Contents

module Gummi
  module Repository
    extend ActiveSupport::Concern

   included do
     include Repobahn::Repository
     after_conversion :set_id_and_version
   end


    module ClassMethods

      def get(id)
        record = db_model.get id
        to_entity_from_db record if record
      end

      def search(&block)
        filtered_search = db_model.new_filtered_search
        yield filtered_search
        result = filtered_search.execute
        Repository::Result.new(result, self, filtered_search.per_page, filtered_search.page)
      end

      def overwrite(entity)
        return false unless entity.valid?
        db_record = db_model.new(entity.attributes)
        db_record.overwrite
      end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gummi-0.1.2 lib/gummi/repository.rb
gummi-0.1.1 lib/gummi/repository.rb
gummi-0.1.0 lib/gummi/repository.rb
gummi-0.0.9 lib/gummi/repository.rb
gummi-0.0.8 lib/gummi/repository.rb
gummi-0.0.7 lib/gummi/repository.rb