cdq 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cdq/version.rb +1 -1
- data/motion/cdq/context.rb +1 -1
- metadata +4 -5
- data/motion/cdq/observer.rb +0 -52
data/lib/cdq/version.rb
CHANGED
data/motion/cdq/context.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cdq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-02-
|
13
|
+
date: 2015-02-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ruby-xcdm
|
@@ -71,7 +71,6 @@ files:
|
|
71
71
|
- motion/cdq/model.rb
|
72
72
|
- motion/cdq/object.rb
|
73
73
|
- motion/cdq/object_proxy.rb
|
74
|
-
- motion/cdq/observer.rb
|
75
74
|
- motion/cdq/partial_predicate.rb
|
76
75
|
- motion/cdq/query.rb
|
77
76
|
- motion/cdq/relationship_query.rb
|
@@ -101,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
100
|
version: '0'
|
102
101
|
segments:
|
103
102
|
- 0
|
104
|
-
hash:
|
103
|
+
hash: 946966330312317208
|
105
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
105
|
none: false
|
107
106
|
requirements:
|
@@ -110,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
109
|
version: '0'
|
111
110
|
segments:
|
112
111
|
- 0
|
113
|
-
hash:
|
112
|
+
hash: 946966330312317208
|
114
113
|
requirements: []
|
115
114
|
rubyforge_project:
|
116
115
|
rubygems_version: 1.8.23
|
data/motion/cdq/observer.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
|
2
|
-
module CDQ
|
3
|
-
class CDQObserver
|
4
|
-
|
5
|
-
include CDQ
|
6
|
-
|
7
|
-
def initialize(actions, klass_or_object, &block)
|
8
|
-
actions = Array(actions)
|
9
|
-
keys = actions.map { |a| key_for_action(a) }
|
10
|
-
|
11
|
-
if klass_or_object.is_a?(Class)
|
12
|
-
test = proc { |obj| obj.is_a?(klass_or_object) }
|
13
|
-
else
|
14
|
-
test = proc { |obj| obj == klass_or_object }
|
15
|
-
end
|
16
|
-
|
17
|
-
@ns_observer = App.notification_center.observe NSManagedObjectContextDidSaveNotification, cdq.contexts.current do |notif|
|
18
|
-
|
19
|
-
actions.zip(keys).each do |action, key|
|
20
|
-
|
21
|
-
objects = notif.userInfo[key]
|
22
|
-
if objects
|
23
|
-
objects.allObjects.select(&test).each do |obj|
|
24
|
-
if block.arity == 2
|
25
|
-
block.call(obj, action)
|
26
|
-
else
|
27
|
-
block.call(obj)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def ns_observer
|
36
|
-
@ns_observer
|
37
|
-
end
|
38
|
-
|
39
|
-
def key_for_action(action)
|
40
|
-
case action
|
41
|
-
when :insert
|
42
|
-
NSInsertedObjectsKey
|
43
|
-
when :update
|
44
|
-
NSUpdatedObjectsKey
|
45
|
-
when :delete
|
46
|
-
NSDeletedObjectsKey
|
47
|
-
else
|
48
|
-
raise ArgumentError.new("No such action #{action.inspect}")
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|