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
- NDllZmQ5MjJhM2QyMWRiMWYzZjgwMjdjNWQ1M2FlN2IyMWViYmExZQ==
4
+ ZDljYjFhMmUzNTYxMjc3MWU5OTdjNGQ0NTM2MTdmMWZmMDk4NGVhYw==
5
5
  data.tar.gz: !binary |-
6
- Mzc0ZDdkNDYxNzMxYWFjMjRlYzM3OTJmNTYzZjNjYjRlMWYwY2E0ZA==
6
+ MDljMjMwZjBmOGVlMTRlOTUyZGU2NTM5ODY2NjAyMzVkNzVhNGRiZQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NDA4YzMxYTUwMGY4Mjk5NzZmNjQzYmNhMGFlOTlmMjc1MGNlYzhlZjg2ODQ0
10
- NDExNWJmNGQzNWRkZmU3ZDlmY2Y1NjUxNjk2N2UwYmNkMzA3NDM0NzMwOTQ2
11
- ZTY5YjAzZGVhOTMwMjRlNGVmODc2NTMwZDg0ZjQxOTI0NzUyZWI=
9
+ MWQ3ZjdiMGE5NzQxZWZjOWI1MTM1YzFmNmM4MTlkMTEyYWE5YTY3NGQ0ZWQ4
10
+ Nzk5NDA5Y2M3YmRlODRiOTNiNjZlZmIwMGE4ODIwMDk5YTlhZDdlNDc0M2Fk
11
+ MGQwOWUzNjM5YzJhZmJjOWQyNTFlZmRiMzUxYTVmYTkyNGNhZTU=
12
12
  data.tar.gz: !binary |-
13
- MzFhNTkyOWRmOTY3NjYzYmM5NDk2NmNhZGUyYzBiNjdlMTA3ZWQyN2NjZTY3
14
- NzdiNGM4M2IwYTNkOTYwNDdiY2I4MjBkNzgxZmVjNzhkMjU1NWViMTUzNTE3
15
- M2Y5ZjczMzM4YWQ2YTQ4NTFiNTM5Nzg2MWUwY2RkMDI4MGEzYTU=
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
- props = args.map { |x| x.split("/").last }
35
- props.each { |x| attr_accessor x }
36
- @_types_mappings = {}
37
- props.each_index { |i| @_types_mappings[props[i]] = args[i] }
38
- @_dependencies = NSSet.setWithArray(props.map(&:to_s))
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
- @_types_mappings ||= {}
79
+ @_type_mappings ||= {}
68
80
  if self.superclass.respondsToSelector :objectionTypeMappings
69
- @_types_mappings.merge self.superclass.objectionTypeMappings
81
+ @_type_mappings.merge self.superclass.objectionTypeMappings
70
82
  else
71
- @_types_mappings
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
- scopes = klass.send(:objectionTypeMappings)[property].to_s.split(NAMESPACE_SEPARTOR).map { |x| x.split("_") }.map { |x| x.map { |y| y.capitalize }.join("") }
6
- klass = scopes.inject(Object) do |const, name|
7
- const.const_get name
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(klass, JSObjectionTypeClass).value
14
+ JSObjectionPropertyInfo.new(dependency_type, JSObjectionTypeClass).value
10
15
  end
11
16
  end
@@ -1,3 +1,3 @@
1
1
  module Objection
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  class Car
2
2
  include Objection
3
- compose_with :engine, :brakes
3
+ compose_with :engine, :brakes, factory: JSObjectFactory
4
4
  end
5
5
 
6
6
  class Engine
@@ -23,6 +23,7 @@ describe "Objection" do
23
23
  @car = @injector.get_object Car
24
24
  @car.engine.class.should.be.same_as Engine
25
25
  @car.brakes.class.should.be.same_as Brakes
26
+ @car.factory.class.should.be.same_as JSObjectFactory
26
27
  end
27
28
 
28
29
  it "has support for singletons" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-objection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin DeWind