motion-objection 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDljYjFhMmUzNTYxMjc3MWU5OTdjNGQ0NTM2MTdmMWZmMDk4NGVhYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDljMjMwZjBmOGVlMTRlOTUyZGU2NTM5ODY2NjAyMzVkNzVhNGRiZQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWQ3ZjdiMGE5NzQxZWZjOWI1MTM1YzFmNmM4MTlkMTEyYWE5YTY3NGQ0ZWQ4
|
10
|
+
Nzk5NDA5Y2M3YmRlODRiOTNiNjZlZmIwMGE4ODIwMDk5YTlhZDdlNDc0M2Fk
|
11
|
+
MGQwOWUzNjM5YzJhZmJjOWQyNTFlZmRiMzUxYTVmYTkyNGNhZTU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MWJjZjdiNjcwNzE0MDU1YmFlOGNhYmI0MzAyMGFhZjAyZDJlZmYzZmZmM2My
|
14
|
+
NzczNjc5NDc1Mzc0ODk5OTU2MzY0MWI0M2NlNDU5MzQ3NGU0ZDAyNzMxN2Jm
|
15
|
+
YWZkNGE5MTkwYTY4YzdmNzY1NGU4NGU4YzBhMTI4M2RkOTc5ZWY=
|
data/README.md
CHANGED
@@ -4,6 +4,7 @@ motion-objection
|
|
4
4
|
Wrapping the dependency injection library [Objection](https://github.com/atomicobject/objection) in RubyMotion.
|
5
5
|
|
6
6
|
[![Build Status](https://travis-ci.org/atomicobject/motion-objection.png)](https://travis-ci.org/atomicobject/motion-objection)
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/motion-objection.png)](http://badge.fury.io/rb/motion-objection)
|
7
8
|
|
8
9
|
## Install
|
9
10
|
```bash
|
@@ -31,11 +31,23 @@ module Objection
|
|
31
31
|
module ClassMethods
|
32
32
|
|
33
33
|
def compose_with(*args)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
@_type_mappings = {}
|
35
|
+
properties = []
|
36
|
+
args.each do |arg|
|
37
|
+
if arg.is_a? Hash
|
38
|
+
arg.each do |k,v|
|
39
|
+
@_type_mappings[k.to_s] = v
|
40
|
+
attr_accessor k
|
41
|
+
properties << k
|
42
|
+
end
|
43
|
+
else
|
44
|
+
prop = arg.split("/").last
|
45
|
+
attr_accessor prop
|
46
|
+
@_type_mappings[prop] = arg
|
47
|
+
properties << prop
|
48
|
+
end
|
49
|
+
end
|
50
|
+
@_dependencies = NSSet.setWithArray(properties.map(&:to_s))
|
39
51
|
end
|
40
52
|
|
41
53
|
def singleton
|
@@ -64,11 +76,11 @@ module Objection
|
|
64
76
|
end
|
65
77
|
|
66
78
|
def objectionTypeMappings
|
67
|
-
@
|
79
|
+
@_type_mappings ||= {}
|
68
80
|
if self.superclass.respondsToSelector :objectionTypeMappings
|
69
|
-
@
|
81
|
+
@_type_mappings.merge self.superclass.objectionTypeMappings
|
70
82
|
else
|
71
|
-
@
|
83
|
+
@_type_mappings
|
72
84
|
end
|
73
85
|
end
|
74
86
|
end
|
@@ -2,10 +2,15 @@ class RubyPropertyReflector
|
|
2
2
|
NAMESPACE_SEPARTOR = "/"
|
3
3
|
|
4
4
|
def self.propertyForClass(klass, andProperty: property)
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
mapping = klass.send(:objectionTypeMappings)[property]
|
6
|
+
if mapping.is_a? Class
|
7
|
+
dependency_type = mapping
|
8
|
+
else
|
9
|
+
scopes = klass.send(:objectionTypeMappings)[property].to_s.split(NAMESPACE_SEPARTOR).map { |x| x.split("_") }.map { |x| x.map { |y| y.capitalize }.join("") }
|
10
|
+
dependency_type = scopes.inject(Object) do |const, name|
|
11
|
+
const.const_get name
|
12
|
+
end
|
8
13
|
end
|
9
|
-
JSObjectionPropertyInfo.new(
|
14
|
+
JSObjectionPropertyInfo.new(dependency_type, JSObjectionTypeClass).value
|
10
15
|
end
|
11
16
|
end
|
data/spec/objection_spec.rb
CHANGED