embedded_record 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -75,7 +75,7 @@ p car.colors_mask # => 3 (2**0 + 2**1)
75
75
 
76
76
  NullObject support:
77
77
 
78
- ```
78
+ ```ruby
79
79
  class Color
80
80
  record nil, :name => "Blank"
81
81
  end
@@ -1,5 +1,5 @@
1
1
  module EmbeddedRecord
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
 
4
4
  def self.included(klass)
5
5
  klass.extend self
@@ -161,7 +161,7 @@ module EmbeddedRecord::Record
161
161
  ##
162
162
  # Returns Array of records ids
163
163
  def ids
164
- records.keys
164
+ @keys ||= []
165
165
  end
166
166
 
167
167
  ##
@@ -173,7 +173,7 @@ module EmbeddedRecord::Record
173
173
  ##
174
174
  # Returns all records
175
175
  def all
176
- records.values
176
+ @records ||= []
177
177
  end
178
178
 
179
179
  ##
@@ -202,9 +202,12 @@ module EmbeddedRecord::Record
202
202
  end
203
203
 
204
204
  if id == nil
205
+ def record.nil?; true end
206
+
205
207
  @null_record = record
206
208
  else
207
- records[id] = record
209
+ ids << id
210
+ all << record
208
211
  end
209
212
  end
210
213
 
@@ -231,11 +234,5 @@ module EmbeddedRecord::Record
231
234
  attr_accessor name
232
235
  end
233
236
  end
234
-
235
- private
236
-
237
- def records
238
- @records ||= {}
239
- end
240
237
  end
241
238
  end
@@ -178,6 +178,7 @@ describe EmbeddedRecord::Record do
178
178
  record nil, :name => "Empty"
179
179
  end
180
180
  @cls.null_record.name.must_equal "Empty"
181
+ @cls.null_record.nil?.must_equal true
181
182
  @cls.all.must_equal []
182
183
  end
183
184
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embedded_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-11-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70207362929780 !ruby/object:Gem::Requirement
16
+ requirement: &70131602869220 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70207362929780
24
+ version_requirements: *70131602869220
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: minitest
27
- requirement: &70207362928920 !ruby/object:Gem::Requirement
27
+ requirement: &70131602868440 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '2.6'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70207362928920
35
+ version_requirements: *70131602868440
36
36
  description:
37
37
  email:
38
38
  - wojtek@wojtekmach.pl