active_hash 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +3 -0
- data/lib/active_hash/base.rb +7 -6
- data/lib/active_hash/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10ab92fe5ae0453d087ce9f904ade8c1664db5c3
|
4
|
+
data.tar.gz: '0964a0f76b8d9321f0c7bcbe136e2dde6a91ed2f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c00058af1e0cc646f6f7e6b3e2b9a3f06e129c1297cd8d59dff7a9b7aff411beb91237bd4999976f8adfecce2244e85da9131332edee3b11eba665402380e40a
|
7
|
+
data.tar.gz: b41cd527f634cb8f57eea675ef2a732e97c808b9409086191b0b28391340d650d980d6b94aded02041856668c8dc5b9f2ae25d72f9b56c32720af599da9e0be0
|
data/CHANGELOG
CHANGED
data/lib/active_hash/base.rb
CHANGED
@@ -90,7 +90,7 @@ module ActiveHash
|
|
90
90
|
|
91
91
|
def insert(record)
|
92
92
|
@records ||= []
|
93
|
-
record
|
93
|
+
record[:id] ||= next_id
|
94
94
|
validate_unique_id(record) if dirty
|
95
95
|
mark_dirty
|
96
96
|
|
@@ -158,7 +158,8 @@ module ActiveHash
|
|
158
158
|
return @records if options.blank?
|
159
159
|
|
160
160
|
# use index if searching by id
|
161
|
-
if
|
161
|
+
if options.key?(:id) || options.key?("id")
|
162
|
+
ids = (options.delete(:id) || options.delete("id"))
|
162
163
|
candidates = Array.wrap(ids).map { |id| find_by_id(id) }
|
163
164
|
end
|
164
165
|
return candidates if options.blank?
|
@@ -319,7 +320,7 @@ module ActiveHash
|
|
319
320
|
method_name = :"#{field}="
|
320
321
|
unless instance_methods.include?(method_name)
|
321
322
|
define_method(method_name) do |new_val|
|
322
|
-
attributes[field] = new_val
|
323
|
+
@attributes[field] = new_val
|
323
324
|
end
|
324
325
|
end
|
325
326
|
end
|
@@ -423,7 +424,7 @@ module ActiveHash
|
|
423
424
|
|
424
425
|
def attributes
|
425
426
|
if self.class.default_attributes
|
426
|
-
self.class.default_attributes.merge @attributes
|
427
|
+
(self.class.default_attributes.merge @attributes).freeze
|
427
428
|
else
|
428
429
|
@attributes
|
429
430
|
end
|
@@ -439,7 +440,7 @@ module ActiveHash
|
|
439
440
|
alias_method :read_attribute, :_read_attribute
|
440
441
|
|
441
442
|
def []=(key, val)
|
442
|
-
attributes[key] = val
|
443
|
+
@attributes[key] = val
|
443
444
|
end
|
444
445
|
|
445
446
|
def id
|
@@ -447,7 +448,7 @@ module ActiveHash
|
|
447
448
|
end
|
448
449
|
|
449
450
|
def id=(id)
|
450
|
-
attributes[:id] = id
|
451
|
+
@attributes[:id] = id
|
451
452
|
end
|
452
453
|
|
453
454
|
alias quoted_id id
|
data/lib/active_hash/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_hash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Dean
|
@@ -29,7 +29,7 @@ authors:
|
|
29
29
|
autorequire:
|
30
30
|
bindir: bin
|
31
31
|
cert_chain: []
|
32
|
-
date: 2017-04-
|
32
|
+
date: 2017-04-20 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: activesupport
|
@@ -87,8 +87,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
87
|
version: '0'
|
88
88
|
requirements: []
|
89
89
|
rubyforge_project:
|
90
|
-
rubygems_version: 2.5.
|
90
|
+
rubygems_version: 2.5.2
|
91
91
|
signing_key:
|
92
92
|
specification_version: 4
|
93
93
|
summary: An ActiveRecord-like model that uses a hash or file as a datasource
|
94
94
|
test_files: []
|
95
|
+
has_rdoc:
|