disposable 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 458a517ee02a889864487c957c7ca81d44b443d8
4
- data.tar.gz: 3b491fa53805ca4f1c4540526d671310e0f34996
3
+ metadata.gz: d481c220836e677da221e7ae1591a24127585210
4
+ data.tar.gz: e93049331639e5a7b7bd98d297ff8bd3b3867a72
5
5
  SHA512:
6
- metadata.gz: 16d6c5a1231d4f85e5f42ab7d2ccac03ae9f2f3bc46a75ddb3f4b49260a7fff3814c2ab3e337a61d06e7733fd5c9d42f263c5f21b010457091864c3e1f8c2e03
7
- data.tar.gz: 3b840942d484cff296d4495bda82eeb9268aff52565e8e385acf675152ffddc47b95d23b6ce6bc1da7015133a748de0654c4e50569ffc91a489d5e714c784ac4
6
+ metadata.gz: fabc3940bfa9356ec38b096ca310550ef7a35f3689576697c621a63022cd3a6b78bf24685b994f14514a185a01727924938e319e5f8235383f7861fc51fd0557
7
+ data.tar.gz: df9dbc4719aefa13c47c579a5af8d4cfc7dbf3a7e7955b903fb0339a2ae697a23206dc8be6c8b00cd84de6105efc8f3c5632db145623b04916b3e70196188355
data/.gitignore CHANGED
@@ -14,3 +14,4 @@ spec/reports
14
14
  test/tmp
15
15
  test/version_tmp
16
16
  tmp
17
+ Gemfile*.lock
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.1.12
2
+
3
+ * Added `Twin::for_collection`. Thanks to @timoschilling for the implementation.
4
+
1
5
  # 0.1.11
2
6
 
3
7
  * `:default` now accepts lambdas, too. Thanks to @johndagostino for implementing this.
data/README.md CHANGED
@@ -251,6 +251,16 @@ In addition to the standard `Array` API the collection adds a handful of additio
251
251
 
252
252
  Again, the model is left alone until you call `sync` or `save`.
253
253
 
254
+ ## Twin Collections
255
+
256
+ To twin a collection of models, you can use `::from_collection`.
257
+
258
+ ```ruby
259
+ SongTwin.from_collection([song, song])
260
+ ```
261
+
262
+ This will decorate every song instance using a fresh twin.
263
+
254
264
  ## Change Tracking
255
265
 
256
266
  The `Changed` module will allow tracking of state changes in all properties, even nested structures.
data/database.sqlite3 CHANGED
Binary file
@@ -71,6 +71,10 @@ module Disposable
71
71
  property(name, options.merge(collection: true), &block)
72
72
  end
73
73
 
74
+ def from_collection(collection)
75
+ collection.collect { |model| new(model) }
76
+ end
77
+
74
78
  private
75
79
  def create_accessors(name, definition)
76
80
  mod = Module.new do
@@ -1,3 +1,3 @@
1
1
  module Disposable
2
- VERSION = "0.1.11"
2
+ VERSION = "0.1.12"
3
3
  end
@@ -0,0 +1,29 @@
1
+ require 'test_helper'
2
+
3
+ class TwinFromCollectionDecoratorTest < MiniTest::Spec
4
+ module Model
5
+ Artist = Struct.new(:id, :name)
6
+ end
7
+
8
+ module Twin
9
+ class Artist < Disposable::Twin
10
+ property :id
11
+ property :name
12
+ end
13
+ end
14
+
15
+ let (:artist1) { Model::Artist.new(1, "AFI") }
16
+ let (:artist2) { Model::Artist.new(2, "Gary Moore") }
17
+ let (:collection) { [artist1, artist2] }
18
+
19
+ describe "from a collection" do
20
+ it do
21
+ twined_collection = Twin::Artist.from_collection(collection)
22
+
23
+ twined_collection[0].must_be_instance_of Twin::Artist
24
+ twined_collection[0].model.must_equal artist1
25
+ twined_collection[1].must_be_instance_of Twin::Artist
26
+ twined_collection[1].model.must_equal artist2
27
+ end
28
+ end
29
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: disposable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-27 00:00:00.000000000 Z
11
+ date: 2015-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uber
@@ -145,15 +145,10 @@ files:
145
145
  - database.sqlite3
146
146
  - disposable.gemspec
147
147
  - gemfiles/Gemfile.rails-2.3
148
- - gemfiles/Gemfile.rails-2.3.lock
149
148
  - gemfiles/Gemfile.rails-3.0
150
- - gemfiles/Gemfile.rails-3.0.lock
151
149
  - gemfiles/Gemfile.rails-3.2
152
- - gemfiles/Gemfile.rails-3.2.lock
153
150
  - gemfiles/Gemfile.rails-4.0
154
- - gemfiles/Gemfile.rails-4.0.lock
155
151
  - gemfiles/Gemfile.rails-4.1
156
- - gemfiles/Gemfile.rails-4.1.lock
157
152
  - lib/disposable.rb
158
153
  - lib/disposable/callback.rb
159
154
  - lib/disposable/composition.rb
@@ -192,6 +187,7 @@ files:
192
187
  - test/twin/default_test.rb
193
188
  - test/twin/expose_test.rb
194
189
  - test/twin/feature_test.rb
190
+ - test/twin/from_collection_test.rb
195
191
  - test/twin/from_test.rb
196
192
  - test/twin/inherit_test.rb
197
193
  - test/twin/option_test.rb
@@ -250,6 +246,7 @@ test_files:
250
246
  - test/twin/default_test.rb
251
247
  - test/twin/expose_test.rb
252
248
  - test/twin/feature_test.rb
249
+ - test/twin/from_collection_test.rb
253
250
  - test/twin/from_test.rb
254
251
  - test/twin/inherit_test.rb
255
252
  - test/twin/option_test.rb
@@ -1,53 +0,0 @@
1
- PATH
2
- remote: ../
3
- specs:
4
- disposable (0.0.5)
5
- representable (~> 2.0.1)
6
- uber
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- actionmailer (2.3.18)
12
- actionpack (= 2.3.18)
13
- actionpack (2.3.18)
14
- activesupport (= 2.3.18)
15
- rack (~> 1.1.0)
16
- activerecord (2.3.18)
17
- activesupport (= 2.3.18)
18
- activeresource (2.3.18)
19
- activesupport (= 2.3.18)
20
- activesupport (2.3.18)
21
- database_cleaner (1.3.0)
22
- minitest (5.0.8)
23
- multi_json (1.10.1)
24
- nokogiri (1.5.11)
25
- rack (1.1.6)
26
- rails (2.3.18)
27
- actionmailer (= 2.3.18)
28
- actionpack (= 2.3.18)
29
- activerecord (= 2.3.18)
30
- activeresource (= 2.3.18)
31
- activesupport (= 2.3.18)
32
- rake (>= 0.8.3)
33
- rake (10.1.0)
34
- representable (2.0.1)
35
- multi_json
36
- nokogiri
37
- uber (~> 0.0.7)
38
- sqlite3 (1.3.8)
39
- uber (0.0.7)
40
-
41
- PLATFORMS
42
- ruby
43
-
44
- DEPENDENCIES
45
- activerecord
46
- bundler (~> 1.3)
47
- database_cleaner
48
- disposable!
49
- minitest
50
- nokogiri (~> 1.5.0)
51
- rails (= 2.3.18)
52
- rake
53
- sqlite3
@@ -1,76 +0,0 @@
1
- PATH
2
- remote: ../
3
- specs:
4
- disposable (0.0.8)
5
- representable (~> 2.0)
6
- uber
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- abstract (1.0.0)
12
- actionpack (3.0.20)
13
- activemodel (= 3.0.20)
14
- activesupport (= 3.0.20)
15
- builder (~> 2.1.2)
16
- erubis (~> 2.6.6)
17
- i18n (~> 0.5.0)
18
- rack (~> 1.2.5)
19
- rack-mount (~> 0.6.14)
20
- rack-test (~> 0.5.7)
21
- tzinfo (~> 0.3.23)
22
- activemodel (3.0.20)
23
- activesupport (= 3.0.20)
24
- builder (~> 2.1.2)
25
- i18n (~> 0.5.0)
26
- activerecord (3.0.20)
27
- activemodel (= 3.0.20)
28
- activesupport (= 3.0.20)
29
- arel (~> 2.0.10)
30
- tzinfo (~> 0.3.23)
31
- activesupport (3.0.20)
32
- arel (2.0.10)
33
- builder (2.1.2)
34
- erubis (2.6.6)
35
- abstract (>= 1.0.0)
36
- i18n (0.5.4)
37
- json (1.8.1)
38
- mini_portile (0.6.2)
39
- minitest (5.4.1)
40
- multi_json (1.11.0)
41
- nokogiri (1.6.6.2)
42
- mini_portile (~> 0.6.0)
43
- rack (1.2.8)
44
- rack-mount (0.6.14)
45
- rack (>= 1.0.0)
46
- rack-test (0.5.7)
47
- rack (>= 1.0)
48
- railties (3.0.20)
49
- actionpack (= 3.0.20)
50
- activesupport (= 3.0.20)
51
- rake (>= 0.8.7)
52
- rdoc (~> 3.4)
53
- thor (~> 0.14.4)
54
- rake (10.3.2)
55
- rdoc (3.12.2)
56
- json (~> 1.4)
57
- representable (2.1.5)
58
- multi_json
59
- nokogiri
60
- uber (~> 0.0.7)
61
- sqlite3 (1.3.10)
62
- thor (0.14.6)
63
- tzinfo (0.3.41)
64
- uber (0.0.13)
65
-
66
- PLATFORMS
67
- ruby
68
-
69
- DEPENDENCIES
70
- activerecord (~> 3.0.11)
71
- bundler (~> 1.3)
72
- disposable!
73
- minitest (= 5.4.1)
74
- railties (~> 3.0.11)
75
- rake
76
- sqlite3
@@ -1,86 +0,0 @@
1
- PATH
2
- remote: ../
3
- specs:
4
- disposable (0.0.8)
5
- representable (~> 2.0)
6
- uber
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- actionpack (3.2.19)
12
- activemodel (= 3.2.19)
13
- activesupport (= 3.2.19)
14
- builder (~> 3.0.0)
15
- erubis (~> 2.7.0)
16
- journey (~> 1.0.4)
17
- rack (~> 1.4.5)
18
- rack-cache (~> 1.2)
19
- rack-test (~> 0.6.1)
20
- sprockets (~> 2.2.1)
21
- activemodel (3.2.19)
22
- activesupport (= 3.2.19)
23
- builder (~> 3.0.0)
24
- activerecord (3.2.19)
25
- activemodel (= 3.2.19)
26
- activesupport (= 3.2.19)
27
- arel (~> 3.0.2)
28
- tzinfo (~> 0.3.29)
29
- activesupport (3.2.19)
30
- i18n (~> 0.6, >= 0.6.4)
31
- multi_json (~> 1.0)
32
- arel (3.0.3)
33
- builder (3.0.4)
34
- erubis (2.7.0)
35
- hike (1.2.3)
36
- i18n (0.6.11)
37
- journey (1.0.4)
38
- json (1.8.1)
39
- mini_portile (0.6.2)
40
- minitest (5.4.1)
41
- multi_json (1.10.1)
42
- nokogiri (1.6.6.2)
43
- mini_portile (~> 0.6.0)
44
- rack (1.4.5)
45
- rack-cache (1.2)
46
- rack (>= 0.4)
47
- rack-ssl (1.3.4)
48
- rack
49
- rack-test (0.6.2)
50
- rack (>= 1.0)
51
- railties (3.2.19)
52
- actionpack (= 3.2.19)
53
- activesupport (= 3.2.19)
54
- rack-ssl (~> 1.3.2)
55
- rake (>= 0.8.7)
56
- rdoc (~> 3.4)
57
- thor (>= 0.14.6, < 2.0)
58
- rake (10.3.2)
59
- rdoc (3.12.2)
60
- json (~> 1.4)
61
- representable (2.1.5)
62
- multi_json
63
- nokogiri
64
- uber (~> 0.0.7)
65
- sprockets (2.2.2)
66
- hike (~> 1.2)
67
- multi_json (~> 1.0)
68
- rack (~> 1.0)
69
- tilt (~> 1.1, != 1.3.0)
70
- sqlite3 (1.3.10)
71
- thor (0.19.1)
72
- tilt (1.4.1)
73
- tzinfo (0.3.41)
74
- uber (0.0.13)
75
-
76
- PLATFORMS
77
- ruby
78
-
79
- DEPENDENCIES
80
- activerecord (~> 3.2.0)
81
- bundler (~> 1.3)
82
- disposable!
83
- minitest (= 5.4.1)
84
- railties (~> 3.2.0)
85
- rake
86
- sqlite3
@@ -1,70 +0,0 @@
1
- PATH
2
- remote: ../
3
- specs:
4
- disposable (0.0.8)
5
- representable (~> 2.0)
6
- uber
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- actionpack (4.0.9)
12
- activesupport (= 4.0.9)
13
- builder (~> 3.1.0)
14
- erubis (~> 2.7.0)
15
- rack (~> 1.5.2)
16
- rack-test (~> 0.6.2)
17
- activemodel (4.0.9)
18
- activesupport (= 4.0.9)
19
- builder (~> 3.1.0)
20
- activerecord (4.0.9)
21
- activemodel (= 4.0.9)
22
- activerecord-deprecated_finders (~> 1.0.2)
23
- activesupport (= 4.0.9)
24
- arel (~> 4.0.0)
25
- activerecord-deprecated_finders (1.0.3)
26
- activesupport (4.0.9)
27
- i18n (~> 0.6, >= 0.6.9)
28
- minitest (~> 4.2)
29
- multi_json (~> 1.3)
30
- thread_safe (~> 0.1)
31
- tzinfo (~> 0.3.37)
32
- arel (4.0.2)
33
- builder (3.1.4)
34
- erubis (2.7.0)
35
- i18n (0.6.11)
36
- mini_portile (0.6.2)
37
- minitest (4.2.0)
38
- multi_json (1.10.1)
39
- nokogiri (1.6.6.2)
40
- mini_portile (~> 0.6.0)
41
- rack (1.5.2)
42
- rack-test (0.6.2)
43
- rack (>= 1.0)
44
- railties (4.0.9)
45
- actionpack (= 4.0.9)
46
- activesupport (= 4.0.9)
47
- rake (>= 0.8.7)
48
- thor (>= 0.18.1, < 2.0)
49
- rake (10.3.2)
50
- representable (2.1.5)
51
- multi_json
52
- nokogiri
53
- uber (~> 0.0.7)
54
- sqlite3 (1.3.10)
55
- thor (0.19.1)
56
- thread_safe (0.3.4)
57
- tzinfo (0.3.41)
58
- uber (0.0.13)
59
-
60
- PLATFORMS
61
- ruby
62
-
63
- DEPENDENCIES
64
- activerecord (~> 4.0.0)
65
- bundler (~> 1.3)
66
- disposable!
67
- minitest (~> 4.2.0)
68
- railties (~> 4.0.0)
69
- rake
70
- sqlite3
@@ -1,73 +0,0 @@
1
- PATH
2
- remote: ../
3
- specs:
4
- disposable (0.0.8)
5
- representable (~> 2.0)
6
- uber
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- actionpack (4.1.5)
12
- actionview (= 4.1.5)
13
- activesupport (= 4.1.5)
14
- rack (~> 1.5.2)
15
- rack-test (~> 0.6.2)
16
- actionview (4.1.5)
17
- activesupport (= 4.1.5)
18
- builder (~> 3.1)
19
- erubis (~> 2.7.0)
20
- activemodel (4.1.5)
21
- activesupport (= 4.1.5)
22
- builder (~> 3.1)
23
- activerecord (4.1.5)
24
- activemodel (= 4.1.5)
25
- activesupport (= 4.1.5)
26
- arel (~> 5.0.0)
27
- activesupport (4.1.5)
28
- i18n (~> 0.6, >= 0.6.9)
29
- json (~> 1.7, >= 1.7.7)
30
- minitest (~> 5.1)
31
- thread_safe (~> 0.1)
32
- tzinfo (~> 1.1)
33
- arel (5.0.1.20140414130214)
34
- builder (3.2.2)
35
- erubis (2.7.0)
36
- i18n (0.6.11)
37
- json (1.8.1)
38
- mini_portile (0.6.2)
39
- minitest (5.4.1)
40
- multi_json (1.11.0)
41
- nokogiri (1.6.6.2)
42
- mini_portile (~> 0.6.0)
43
- rack (1.5.2)
44
- rack-test (0.6.2)
45
- rack (>= 1.0)
46
- railties (4.1.5)
47
- actionpack (= 4.1.5)
48
- activesupport (= 4.1.5)
49
- rake (>= 0.8.7)
50
- thor (>= 0.18.1, < 2.0)
51
- rake (10.3.2)
52
- representable (2.1.5)
53
- multi_json
54
- nokogiri
55
- uber (~> 0.0.7)
56
- sqlite3 (1.3.10)
57
- thor (0.19.1)
58
- thread_safe (0.3.4)
59
- tzinfo (1.2.2)
60
- thread_safe (~> 0.1)
61
- uber (0.0.13)
62
-
63
- PLATFORMS
64
- ruby
65
-
66
- DEPENDENCIES
67
- activerecord (~> 4.1.0)
68
- bundler (~> 1.3)
69
- disposable!
70
- minitest (= 5.4.1)
71
- railties (~> 4.1.0)
72
- rake
73
- sqlite3