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