Class: CDQ::CDQObject

Inherits:
Object
  • Object
show all
Includes:
CDQ
Defined in:
motion/cdq.rb,
motion/cdq/object.rb

Direct Known Subclasses

CDQObjectProxy, CDQPartialPredicate, CDQQuery

Instance Method Summary collapse

Methods included from CDQ

#cdq

Instance Method Details

#background(*args, &block) ⇒ Object


44
45
46
# File 'motion/cdq/object.rb', line 44

def background(*args, &block)
  contexts.background(*args, &block)
end

#contextsObject


8
9
10
# File 'motion/cdq/object.rb', line 8

def contexts
  @@context_manager ||= CDQContextManager.new(store_manager: stores)
end

#find(oid) ⇒ Object


48
49
50
51
52
# File 'motion/cdq/object.rb', line 48

def find(oid)
  url = NSURL.URLWithString(oid)
  object_id = stores.current.managedObjectIDForURIRepresentation(url)
  contexts.current.existingObjectWithID(object_id, error: nil)
end

#modelsObject


16
17
18
# File 'motion/cdq/object.rb', line 16

def models
  @@model_manager ||= CDQModelManager.new
end

#reset!(opts = {}) ⇒ Object


20
21
22
23
24
25
# File 'motion/cdq/object.rb', line 20

def reset!(opts = {})
  @@context_manager.reset! if @@context_manager
  @@context_manager = nil
  @@store_manager.reset! if @@store_manager
  @@store_manager = nil
end

#save(*args) ⇒ Object


40
41
42
# File 'motion/cdq/object.rb', line 40

def save(*args)
  contexts.save(*args)
end

#setup(opts = {}) ⇒ Object


27
28
29
30
31
32
33
34
35
36
37
38
# File 'motion/cdq/object.rb', line 27

def setup(opts = {})
  if opts[:context]
    contexts.push(opts[:context])
    return true
  elsif opts[:store]
    stores.current = opts[:store]
  elsif opts[:model]
    models.current = opts[:model]
  end
  contexts.push(NSMainQueueConcurrencyType)
  true
end

#storesObject


12
13
14
# File 'motion/cdq/object.rb', line 12

def stores
  @@store_manager ||= CDQStoreManager.new(model_manager: models)
end