disposable 0.1.12 → 0.1.13

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: d481c220836e677da221e7ae1591a24127585210
4
- data.tar.gz: e93049331639e5a7b7bd98d297ff8bd3b3867a72
3
+ metadata.gz: da82ae628d302989838d30e7ee1f493f4ea4ed74
4
+ data.tar.gz: d96903d216a97508a08052ca5d33ec17bad2b3d5
5
5
  SHA512:
6
- metadata.gz: fabc3940bfa9356ec38b096ca310550ef7a35f3689576697c621a63022cd3a6b78bf24685b994f14514a185a01727924938e319e5f8235383f7861fc51fd0557
7
- data.tar.gz: df9dbc4719aefa13c47c579a5af8d4cfc7dbf3a7e7955b903fb0339a2ae697a23206dc8be6c8b00cd84de6105efc8f3c5632db145623b04916b3e70196188355
6
+ metadata.gz: e9b1cc05facbe532e3c46900cc5afc1bc54c17607ee43ff4b87e8270d3a2d4c1f393261acc54a8c1a52adf556cf9f18aa617b1d7f5194ba699284007c78c44fb
7
+ data.tar.gz: fa527244dab259db4be2632d17fce579ac4a696dc656400778c272902b61a18973c83bc4673a54b757a58d549ad6aeef552e0b1d31d40ec78e91bfe66626ce58
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.1.13
2
+
3
+ * Allow representable ~> 2.2.
4
+
1
5
  # 0.1.12
2
6
 
3
7
  * Added `Twin::for_collection`. Thanks to @timoschilling for the implementation.
data/Gemfile CHANGED
@@ -3,5 +3,4 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in disposable.gemspec
4
4
  gemspec
5
5
 
6
- # gem 'representable', path: '../representable'
7
- # gem "uber", path: "../uber"
6
+ gem 'representable', path: '../representable'
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "uber"
22
- spec.add_dependency "representable", ">= 2.2.3", "<= 2.3.0"
22
+ spec.add_dependency "representable", ">= 2.2.3", "< 3.0.0"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
25
25
  spec.add_development_dependency "rake"
@@ -1,3 +1,3 @@
1
1
  module Disposable
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.13"
3
3
  end
@@ -1,263 +1,263 @@
1
- require "test_helper"
2
- require "disposable/twin"
3
- require "ostruct"
4
-
5
- module Model
6
- Song = Struct.new(:id, :title)
7
- Album = Struct.new(:id, :name, :songs)
8
- end
9
-
10
- # thoughts:
11
- # a twin should be a proxy between the incoming API instructions (form hash) and the models to write to.
12
- # e.g. when deleting certain items in a collection, this could be held in memory before written to DB.
13
- # reason: a twin can be validated (e.g. is current user allowed to remove item 1 from collection abc?)
14
- # before the application state is actually altered in the DB.
15
- # that would open a clean workflow: API calls --> twin state change --> validation --> "rollback" / save
16
-
17
- module Representable
18
- class Semantics
19
- class Semantic
20
- def self.existing_item_for(fragment, options)
21
- # return unless model.songs.collect { |s| s.id.to_s }.include?(fragment["id"].to_s)
22
- options.binding.get.find { |s| s.id.to_s == fragment["id"].to_s }
23
- end
24
- end
25
-
26
- class SkipExisting < Semantic
27
- def self.call(model, fragment, index, options)
28
- return unless existing_item_for(fragment, options)
29
-
30
- Skip.new(fragment)
31
- end
32
- end
33
-
34
- class Add < Semantic # old representable behavior.
35
- def self.call(model, fragment, index, options)
36
- binding = options.binding.clone
37
- binding.instance_variable_get(:@definition).delete!(:instance) # FIXME: sucks!
38
- Representable::Deserializer.new(binding).(fragment, options.user_options) # Song.new
39
- end
40
- end
1
+ # require "test_helper"
2
+ # require "disposable/twin"
3
+ # require "ostruct"
4
+
5
+ # module Model
6
+ # Song = Struct.new(:id, :title)
7
+ # Album = Struct.new(:id, :name, :songs)
8
+ # end
9
+
10
+ # # thoughts:
11
+ # # a twin should be a proxy between the incoming API instructions (form hash) and the models to write to.
12
+ # # e.g. when deleting certain items in a collection, this could be held in memory before written to DB.
13
+ # # reason: a twin can be validated (e.g. is current user allowed to remove item 1 from collection abc?)
14
+ # # before the application state is actually altered in the DB.
15
+ # # that would open a clean workflow: API calls --> twin state change --> validation --> "rollback" / save
16
+
17
+ # module Representable
18
+ # class Semantics
19
+ # class Semantic
20
+ # def self.existing_item_for(fragment, options)
21
+ # # return unless model.songs.collect { |s| s.id.to_s }.include?(fragment["id"].to_s)
22
+ # options.binding.get.find { |s| s.id.to_s == fragment["id"].to_s }
23
+ # end
24
+ # end
25
+
26
+ # class SkipExisting < Semantic
27
+ # def self.call(model, fragment, index, options)
28
+ # return unless existing_item_for(fragment, options)
29
+
30
+ # Skip.new(fragment)
31
+ # end
32
+ # end
33
+
34
+ # class Add < Semantic # old representable behavior.
35
+ # def self.call(model, fragment, index, options)
36
+ # binding = options.binding.clone
37
+ # binding.instance_variable_get(:@definition).delete!(:instance) # FIXME: sucks!
38
+ # Representable::Deserializer.new(binding).(fragment, options.user_options) # Song.new
39
+ # end
40
+ # end
41
41
 
42
- class UpdateExisting < Semantic
43
- def self.call(model, fragment, index, options)
44
- return unless res = existing_item_for(fragment, options)
45
-
46
- Update.new(res)
47
- end
48
- end
42
+ # class UpdateExisting < Semantic
43
+ # def self.call(model, fragment, index, options)
44
+ # return unless res = existing_item_for(fragment, options)
45
+
46
+ # Update.new(res)
47
+ # end
48
+ # end
49
49
 
50
50
 
51
- class Skip < OpenStruct
52
- end
51
+ # class Skip < OpenStruct
52
+ # end
53
53
 
54
- class Remove < Skip
55
- def self.call(model, fragment, index, options)
56
- return unless fragment["_action"] == "remove" # TODO: check if feature enabled.
54
+ # class Remove < Skip
55
+ # def self.call(model, fragment, index, options)
56
+ # return unless fragment["_action"] == "remove" # TODO: check if feature enabled.
57
57
 
58
- Remove.new(fragment)
59
- end
60
- end
58
+ # Remove.new(fragment)
59
+ # end
60
+ # end
61
61
 
62
- require 'delegate'
63
- class Update < SimpleDelegator
64
- end
62
+ # require 'delegate'
63
+ # class Update < SimpleDelegator
64
+ # end
65
65
 
66
- # Per parsed collection item, mark the to-be-populated model for removal, skipping or adding.
67
- # This code is called right before #from_format is called on the model.
68
- # Semantical behavior is inferred from the fragment making this code document- and format-specific.
69
-
70
- # remove: unlink from association
71
- # skip_existing
72
- # update_existing
73
- # add
74
- # [destroy]
75
- # callable
76
-
77
- # default behavior: - add_new
78
-
79
- class Instance
80
- include Uber::Callable
81
-
82
- def call(model, fragment, index, options)
83
- semantics = options.binding[:semantics]
84
-
85
- # loop through semantics, the first that returns something wins.
86
- semantics.each do |semantic|
87
- res = semantic.(model, fragment, index, options) and return res
88
- end
89
- end
90
- end
91
-
92
- class Setter
93
- include Uber::Callable
94
-
95
- def call(model, values, options)
96
- remove_items = values.find_all { |i| i.instance_of?(Representable::Semantics::Remove) }
97
- # add_items = values.find_all { |i| i.instance_of?(Add) }.collect(&:model)
98
- add_items = values - remove_items
99
-
100
- skip_items = values.find_all { |i| i.instance_of?(Representable::Semantics::Skip) }
101
- skip_items += values.find_all { |i| i.instance_of?(Representable::Semantics::Update) } # TODO: merge with above!
102
-
103
- # add_items = values.find_all { |i| i.instance_of?(Add) }.collect(&:model)
104
- add_items = add_items - skip_items
105
-
106
- # DISCUSS: collection#[]= will call save
107
- # what does #+= and #-= do?
108
- # how do we prevent adding already existing items twice?
109
-
110
- model.songs += add_items
111
- model.songs -= remove_items.collect { |i| model.songs.find { |s| s.id.to_s == i.id.to_s } }
112
- end
113
- end
114
- end
115
- end
116
-
117
- class AlbumDecorator < Representable::Decorator
118
- include Representable::Hash
119
-
120
- collection :songs,
121
-
122
- # semantics: [:skip_existing, :add, :remove],
123
- semantics: [Representable::Semantics::Remove, Representable::Semantics::SkipExisting, Representable::Semantics::Add],
66
+ # # Per parsed collection item, mark the to-be-populated model for removal, skipping or adding.
67
+ # # This code is called right before #from_format is called on the model.
68
+ # # Semantical behavior is inferred from the fragment making this code document- and format-specific.
69
+
70
+ # # remove: unlink from association
71
+ # # skip_existing
72
+ # # update_existing
73
+ # # add
74
+ # # [destroy]
75
+ # # callable
76
+
77
+ # # default behavior: - add_new
78
+
79
+ # class Instance
80
+ # include Uber::Callable
81
+
82
+ # def call(model, fragment, index, options)
83
+ # semantics = options.binding[:semantics]
84
+
85
+ # # loop through semantics, the first that returns something wins.
86
+ # semantics.each do |semantic|
87
+ # res = semantic.(model, fragment, index, options) and return res
88
+ # end
89
+ # end
90
+ # end
91
+
92
+ # class Setter
93
+ # include Uber::Callable
94
+
95
+ # def call(model, values, options)
96
+ # remove_items = values.find_all { |i| i.instance_of?(Representable::Semantics::Remove) }
97
+ # # add_items = values.find_all { |i| i.instance_of?(Add) }.collect(&:model)
98
+ # add_items = values - remove_items
99
+
100
+ # skip_items = values.find_all { |i| i.instance_of?(Representable::Semantics::Skip) }
101
+ # skip_items += values.find_all { |i| i.instance_of?(Representable::Semantics::Update) } # TODO: merge with above!
102
+
103
+ # # add_items = values.find_all { |i| i.instance_of?(Add) }.collect(&:model)
104
+ # add_items = add_items - skip_items
105
+
106
+ # # DISCUSS: collection#[]= will call save
107
+ # # what does #+= and #-= do?
108
+ # # how do we prevent adding already existing items twice?
109
+
110
+ # model.songs += add_items
111
+ # model.songs -= remove_items.collect { |i| model.songs.find { |s| s.id.to_s == i.id.to_s } }
112
+ # end
113
+ # end
114
+ # end
115
+ # end
116
+
117
+ # class AlbumDecorator < Representable::Decorator
118
+ # include Representable::Hash
119
+
120
+ # collection :songs,
121
+
122
+ # # semantics: [:skip_existing, :add, :remove],
123
+ # semantics: [Representable::Semantics::Remove, Representable::Semantics::SkipExisting, Representable::Semantics::Add],
124
124
 
125
- instance: Representable::Semantics::Instance.new,
126
- pass_options: true,
127
- setter: Representable::Semantics::Setter.new,
125
+ # instance: Representable::Semantics::Instance.new,
126
+ # pass_options: true,
127
+ # setter: Representable::Semantics::Setter.new,
128
128
 
129
129
 
130
- class: Model::Song do # add new to existing collection.
130
+ # class: Model::Song do # add new to existing collection.
131
131
 
132
- # only add new songs
133
- property :title
134
- end
135
- end
132
+ # # only add new songs
133
+ # property :title
134
+ # end
135
+ # end
136
136
 
137
137
 
138
138
 
139
- class ApiSemanticsTest < MiniTest::Spec
140
- it "xxx" do
141
- album = Model::Album.new(1, "And So I Watch You From Afar", [Model::Song.new(2, "Solidarity"), Model::Song.new(0, "Tale That Wasn't Right")])
139
+ # class ApiSemanticsTest < MiniTest::Spec
140
+ # it "xxx" do
141
+ # album = Model::Album.new(1, "And So I Watch You From Afar", [Model::Song.new(2, "Solidarity"), Model::Song.new(0, "Tale That Wasn't Right")])
142
142
 
143
- decorator = AlbumDecorator.new(album)
144
- decorator.from_hash({"songs" => [
145
- {"id" => 2, "title" => "Solidarity, but wrong title"}, # skip
146
- {"id" => 0, "title" => "Tale That Wasn't Right, but wrong title", "_action" => "remove"}, # delete
147
- {"id" => 4, "title" => "Capture Castles"} # add, default.
148
- ]})
149
- # missing: allow updating specific/all items in collection.
143
+ # decorator = AlbumDecorator.new(album)
144
+ # decorator.from_hash({"songs" => [
145
+ # {"id" => 2, "title" => "Solidarity, but wrong title"}, # skip
146
+ # {"id" => 0, "title" => "Tale That Wasn't Right, but wrong title", "_action" => "remove"}, # delete
147
+ # {"id" => 4, "title" => "Capture Castles"} # add, default.
148
+ # ]})
149
+ # # missing: allow updating specific/all items in collection.
150
150
 
151
- decorator.represented.songs.inspect.must_equal %{[#<struct Model::Song id=2, title="Solidarity">, #<struct Model::Song id=nil, title="Capture Castles">]}
152
- end
151
+ # decorator.represented.songs.inspect.must_equal %{[#<struct Model::Song id=2, title="Solidarity">, #<struct Model::Song id=nil, title="Capture Castles">]}
152
+ # end
153
153
 
154
- end
154
+ # end
155
155
 
156
- class RemoveFlagSetButNotEnabled < MiniTest::Spec
157
- class AlbumDecorator < Representable::Decorator
158
- include Representable::Hash
156
+ # class RemoveFlagSetButNotEnabled < MiniTest::Spec
157
+ # class AlbumDecorator < Representable::Decorator
158
+ # include Representable::Hash
159
159
 
160
- collection :songs,
161
- # semantics: [:skip_existing, :add, :remove],
162
- semantics: [Representable::Semantics::SkipExisting, Representable::Semantics::Add],
160
+ # collection :songs,
161
+ # # semantics: [:skip_existing, :add, :remove],
162
+ # semantics: [Representable::Semantics::SkipExisting, Representable::Semantics::Add],
163
163
 
164
- instance: Representable::Semantics::Instance.new,
165
- pass_options: true,
166
- setter: Representable::Semantics::Setter.new,
167
- class: Model::Song do
168
- property :title
169
- end
170
- end
164
+ # instance: Representable::Semantics::Instance.new,
165
+ # pass_options: true,
166
+ # setter: Representable::Semantics::Setter.new,
167
+ # class: Model::Song do
168
+ # property :title
169
+ # end
170
+ # end
171
171
 
172
- it "doesn't remove when semantic is not enabled" do
173
- album = Model::Album.new(1, "And So I Watch You From Afar", [Model::Song.new(2, "Solidarity"), Model::Song.new(0, "Tale That Wasn't Right")])
172
+ # it "doesn't remove when semantic is not enabled" do
173
+ # album = Model::Album.new(1, "And So I Watch You From Afar", [Model::Song.new(2, "Solidarity"), Model::Song.new(0, "Tale That Wasn't Right")])
174
174
 
175
- decorator = AlbumDecorator.new(album)
176
- decorator.from_hash({"songs" => [
177
- {"id" => 2, "title" => "Solidarity, updated!"}, # update
178
- {"id" => 0, "title" => "Tale That Wasn't Right, but wrong title", "_action" => "remove"}, # delete, but don't!
179
- {"title" => "Rise And Fall"}
180
- ]})
175
+ # decorator = AlbumDecorator.new(album)
176
+ # decorator.from_hash({"songs" => [
177
+ # {"id" => 2, "title" => "Solidarity, updated!"}, # update
178
+ # {"id" => 0, "title" => "Tale That Wasn't Right, but wrong title", "_action" => "remove"}, # delete, but don't!
179
+ # {"title" => "Rise And Fall"}
180
+ # ]})
181
181
 
182
- decorator.represented.songs.inspect.must_equal %{[#<struct Model::Song id=2, title=\"Solidarity\">, #<struct Model::Song id=0, title=\"Tale That Wasn't Right\">, #<struct Model::Song id=nil, title=\"Rise And Fall\">]}
183
- end
184
- end
182
+ # decorator.represented.songs.inspect.must_equal %{[#<struct Model::Song id=2, title=\"Solidarity\">, #<struct Model::Song id=0, title=\"Tale That Wasn't Right\">, #<struct Model::Song id=nil, title=\"Rise And Fall\">]}
183
+ # end
184
+ # end
185
185
 
186
- class UserCallableTest < MiniTest::Spec
187
- class MyOwnSemantic < Representable::Semantics::Semantic
188
- def self.call(model, fragment, index, options)
189
- if fragment["title"] =~ /Solidarity/
190
- return Representable::Semantics::Skip.new(fragment)
191
- end
192
- end
193
- end
186
+ # class UserCallableTest < MiniTest::Spec
187
+ # class MyOwnSemantic < Representable::Semantics::Semantic
188
+ # def self.call(model, fragment, index, options)
189
+ # if fragment["title"] =~ /Solidarity/
190
+ # return Representable::Semantics::Skip.new(fragment)
191
+ # end
192
+ # end
193
+ # end
194
194
 
195
- class AlbumDecorator < Representable::Decorator
196
- include Representable::Hash
195
+ # class AlbumDecorator < Representable::Decorator
196
+ # include Representable::Hash
197
197
 
198
- collection :songs,
199
- semantics: [MyOwnSemantic, Representable::Semantics::Add],
198
+ # collection :songs,
199
+ # semantics: [MyOwnSemantic, Representable::Semantics::Add],
200
200
 
201
- instance: Representable::Semantics::Instance.new,
202
- pass_options: true,
203
- setter: Representable::Semantics::Setter.new,
204
- class: Model::Song do
205
- property :title
206
- end
207
- end
201
+ # instance: Representable::Semantics::Instance.new,
202
+ # pass_options: true,
203
+ # setter: Representable::Semantics::Setter.new,
204
+ # class: Model::Song do
205
+ # property :title
206
+ # end
207
+ # end
208
208
 
209
- it do
210
- album = Model::Album.new(1, "And So I Watch You From Afar", [Model::Song.new(2, "Solidarity"), Model::Song.new(0, "Tale That Wasn't Right")])
209
+ # it do
210
+ # album = Model::Album.new(1, "And So I Watch You From Afar", [Model::Song.new(2, "Solidarity"), Model::Song.new(0, "Tale That Wasn't Right")])
211
211
 
212
- decorator = AlbumDecorator.new(album)
213
- decorator.from_hash({"songs" => [
214
- {"id" => 2, "title" => "Solidarity, updated!"}, # update
215
- {"title" => "Rise And Fall"}
216
- ]})
212
+ # decorator = AlbumDecorator.new(album)
213
+ # decorator.from_hash({"songs" => [
214
+ # {"id" => 2, "title" => "Solidarity, updated!"}, # update
215
+ # {"title" => "Rise And Fall"}
216
+ # ]})
217
217
 
218
- decorator.represented.songs.inspect.must_equal %{[#<struct Model::Song id=2, title=\"Solidarity\">, #<struct Model::Song id=0, title=\"Tale That Wasn't Right\">, #<struct Model::Song id=nil, title=\"Rise And Fall\">]}
219
- end
220
- end
218
+ # decorator.represented.songs.inspect.must_equal %{[#<struct Model::Song id=2, title=\"Solidarity\">, #<struct Model::Song id=0, title=\"Tale That Wasn't Right\">, #<struct Model::Song id=nil, title=\"Rise And Fall\">]}
219
+ # end
220
+ # end
221
221
 
222
222
 
223
- class ApiSemanticsWithUpdate < MiniTest::Spec
224
- class AlbumDecorator < Representable::Decorator
225
- include Representable::Hash
223
+ # class ApiSemanticsWithUpdate < MiniTest::Spec
224
+ # class AlbumDecorator < Representable::Decorator
225
+ # include Representable::Hash
226
226
 
227
- collection :songs,
227
+ # collection :songs,
228
228
 
229
- semantics: [Representable::Semantics::Remove, Representable::Semantics::UpdateExisting, Representable::Semantics::Add],
230
-
231
- instance: Representable::Semantics::Instance.new,
232
- pass_options: true,
233
- class: Model::Song,
234
-
235
- setter: Representable::Semantics::Setter.new do # add new to existing collection.
236
-
237
- # only add new songs
238
- property :title
239
- end
240
- end
241
-
242
- it do
243
- album = Model::Album.new(1, "And So I Watch You From Afar", [Model::Song.new(2, "Solidarity"), Model::Song.new(0, "Tale That Wasn't Right")])
244
-
245
- decorator = AlbumDecorator.new(album)
246
- decorator.from_hash({"songs" => [
247
- {"id" => 2, "title" => "Solidarity, updated!"}, # update
248
- {"id" => 0, "title" => "Tale That Wasn't Right, but wrong title", "_action" => "remove"}, # delete
249
- {"id" => 4, "title" => "Capture Castles"}, # add, default. # FIXME: this tests adding with id, keep this.
250
- {"title" => "Rise And Fall"}
251
- ]})
252
- # missing: allow updating specific/all items in collection.
253
-
254
- puts decorator.represented.songs.inspect
255
-
256
-
257
- decorator.represented.songs.inspect.must_equal %{[#<struct Model::Song id=2, title="Solidarity, updated!">, #<struct Model::Song id=nil, title="Capture Castles">, #<struct Model::Song id=nil, title=\"Rise And Fall\">]}
258
- end
259
- end
260
- # [
261
- # {"_action": "add"},
262
- # {"id": 2, "_action": "remove"}
263
- # ]
229
+ # semantics: [Representable::Semantics::Remove, Representable::Semantics::UpdateExisting, Representable::Semantics::Add],
230
+
231
+ # instance: Representable::Semantics::Instance.new,
232
+ # pass_options: true,
233
+ # class: Model::Song,
234
+
235
+ # setter: Representable::Semantics::Setter.new do # add new to existing collection.
236
+
237
+ # # only add new songs
238
+ # property :title
239
+ # end
240
+ # end
241
+
242
+ # it do
243
+ # album = Model::Album.new(1, "And So I Watch You From Afar", [Model::Song.new(2, "Solidarity"), Model::Song.new(0, "Tale That Wasn't Right")])
244
+
245
+ # decorator = AlbumDecorator.new(album)
246
+ # decorator.from_hash({"songs" => [
247
+ # {"id" => 2, "title" => "Solidarity, updated!"}, # update
248
+ # {"id" => 0, "title" => "Tale That Wasn't Right, but wrong title", "_action" => "remove"}, # delete
249
+ # {"id" => 4, "title" => "Capture Castles"}, # add, default. # FIXME: this tests adding with id, keep this.
250
+ # {"title" => "Rise And Fall"}
251
+ # ]})
252
+ # # missing: allow updating specific/all items in collection.
253
+
254
+ # puts decorator.represented.songs.inspect
255
+
256
+
257
+ # decorator.represented.songs.inspect.must_equal %{[#<struct Model::Song id=2, title="Solidarity, updated!">, #<struct Model::Song id=nil, title="Capture Castles">, #<struct Model::Song id=nil, title=\"Rise And Fall\">]}
258
+ # end
259
+ # end
260
+ # # [
261
+ # # {"_action": "add"},
262
+ # # {"id": 2, "_action": "remove"}
263
+ # # ]
@@ -32,28 +32,26 @@ end
32
32
 
33
33
  ActiveRecord::Base.establish_connection(
34
34
  :adapter => "sqlite3",
35
- :database => "#{Dir.pwd}/database.sqlite3"
35
+ :database => ":memory:"
36
36
  )
37
37
 
38
- # uncomment this once to create a database for testing:
39
-
40
- # ActiveRecord::Schema.define do
41
- # create_table :artists do |table|
42
- # table.column :name, :string
43
- # table.timestamps
44
- # end
45
- # create_table :songs do |table|
46
- # table.column :title, :string
47
- # table.column :artist_id, :integer
48
- # table.column :album_id, :integer
49
- # table.timestamps
50
- # end
51
- # create_table :albums do |table|
52
- # table.column :name, :string
53
- # table.column :artist_id, :integer
54
- # table.timestamps
55
- # end
56
- # end
38
+ ActiveRecord::Schema.define do
39
+ create_table :artists do |table|
40
+ table.column :name, :string
41
+ table.timestamps
42
+ end
43
+ create_table :songs do |table|
44
+ table.column :title, :string
45
+ table.column :artist_id, :integer
46
+ table.column :album_id, :integer
47
+ table.timestamps
48
+ end
49
+ create_table :albums do |table|
50
+ table.column :name, :string
51
+ table.column :artist_id, :integer
52
+ table.timestamps
53
+ end
54
+ end
57
55
 
58
56
  module Disposable
59
57
  module Comparable
@@ -27,11 +27,9 @@ class ProcessInlineTest < MiniTest::Spec
27
27
  end
28
28
 
29
29
  it do
30
- twin = AlbumTwin.new(Album.new(Object, Object, OpenStruct.new(composer: OpenStruct.new(composer: nil))))
30
+ twin = AlbumTwin.new(Album.new(Object, Object))
31
31
  assert ! (twin.class < InlineTwin)
32
32
  assert (twin.artist.class < InlineTwin)
33
33
  assert ! (twin.composer.class < InlineTwin)
34
-
35
- twin.recursive_composer.composer.composer.must_equal nil
36
34
  end
37
35
  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.12
4
+ version: 0.1.13
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-09-10 00:00:00.000000000 Z
11
+ date: 2015-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uber
@@ -31,9 +31,9 @@ dependencies:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.2.3
34
- - - "<="
34
+ - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: 2.3.0
36
+ version: 3.0.0
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -41,9 +41,9 @@ dependencies:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: 2.2.3
44
- - - "<="
44
+ - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: 2.3.0
46
+ version: 3.0.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -142,7 +142,6 @@ files:
142
142
  - LICENSE.txt
143
143
  - README.md
144
144
  - Rakefile
145
- - database.sqlite3
146
145
  - disposable.gemspec
147
146
  - gemfiles/Gemfile.rails-2.3
148
147
  - gemfiles/Gemfile.rails-3.0
@@ -262,4 +261,3 @@ test_files:
262
261
  - test/twin/twin_test.rb
263
262
  - test/twin/virtual_test.rb
264
263
  - test/twin/writeable_test.rb
265
- has_rdoc:
Binary file