Class: CouchbaseOrm::CollectionProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase-orm/proxies/collection_proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(proxyfied) ⇒ CollectionProxy

Returns a new instance of CollectionProxy.



37
38
39
40
# File 'lib/couchbase-orm/proxies/collection_proxy.rb', line 37

def initialize(proxyfied)
    raise "Must proxy a non nil object" if proxyfied.nil?
    @proxyfied = proxyfied
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object

:nocov:



47
48
49
# File 'lib/couchbase-orm/proxies/collection_proxy.rb', line 47

def method_missing(name, *args, **options, &block)
    @proxyfied.public_send(name, *args, **options, &block)
end

Instance Method Details

#get(id, **options) ⇒ Object



10
11
12
13
14
# File 'lib/couchbase-orm/proxies/collection_proxy.rb', line 10

def get(id, **options)
    @proxyfied.get(id, Couchbase::Options::Get.new(**options))
rescue Couchbase::Error::DocumentNotFound
    nil
end

#get!(id, **options) ⇒ Object



6
7
8
# File 'lib/couchbase-orm/proxies/collection_proxy.rb', line 6

def get!(id, **options)
    @proxyfied.get(id, Couchbase::Options::Get.new(**options))
end

#get_multi(*ids, **options) ⇒ Object



23
24
25
# File 'lib/couchbase-orm/proxies/collection_proxy.rb', line 23

def get_multi(*ids, **options)
    @proxyfied.get_multi(*ids, Couchbase::Options::GetMulti.new(**options))
end

#get_multi!(*ids, **options) ⇒ Object



16
17
18
19
20
21
# File 'lib/couchbase-orm/proxies/collection_proxy.rb', line 16

def get_multi!(*ids, **options)
    result = @proxyfied.get_multi(*ids, Couchbase::Options::GetMulti.new(**options))
    first_result_with_error = result.find(&:error)
    raise first_result_with_error.error if first_result_with_error
    result
end

#remove(id, **options) ⇒ Object



31
32
33
34
35
# File 'lib/couchbase-orm/proxies/collection_proxy.rb', line 31

def remove(id, **options)
    @proxyfied.remove(id, Couchbase::Options::Remove.new(**options))
rescue Couchbase::Error::DocumentNotFound
    nil
end

#remove!(id, **options) ⇒ Object



27
28
29
# File 'lib/couchbase-orm/proxies/collection_proxy.rb', line 27

def remove!(id, **options)
    @proxyfied.remove(id, Couchbase::Options::Remove.new(**options))
end