active_hash 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +5 -0
- data/README.md +11 -0
- data/active_hash.gemspec +2 -2
- data/lib/active_hash/base.rb +5 -0
- data/lib/active_hash/version.rb +1 -1
- data/lib/active_yaml/base.rb +1 -1
- data/lib/enum/enum.rb +3 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a92e60195ef8ad5fbd50981978f78755d5f670ba04dd3b97604454e9c466e14
|
4
|
+
data.tar.gz: a00b0870924b1cc46e5f0fc63a75847bcd54532f4f6e8c9c0367c7058ec079e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1419297eb2d3427cad33b04bf4a29c646b9852e89008df56269128635fabe55a16742a9c9f4a0de4cd8fd398bddfb1dcd36730f3fd63283ba92764c1f83260e4
|
7
|
+
data.tar.gz: a89ca9f078a9258d5c6f079505abffe438250444e2afa45f2f9d0934afa4ed29cbb06de211a6e392905887c5770724f873541a8f84e58253385dc93d00a35ef1
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
2018-04-05 (v2.1.0)
|
2
|
+
- Allow to use ERB (embedded ruby) in yml files [#160](https://github.com/zilkey/active_hash/pull/160) Thanks, @UgoMare
|
3
|
+
- Add `ActiveHash::Base.polymorphic_name` [#162](https://github.com/zilkey/active_hash/pull/162)
|
4
|
+
- Fix to be able to use enum accessor constant with same name as top-level constant[#161](https://github.com/zilkey/active_hash/pull/161) Thanks, @yujideveloper
|
5
|
+
|
1
6
|
2018-02-27 (v2.0.0)
|
2
7
|
- Drop old Ruby and Rails support [#157](https://github.com/zilkey/active_hash/pull/157)
|
3
8
|
- Don't generate instance accessors for class attributes [#136](https://github.com/zilkey/active_hash/pull/136) Thanks, @rainhead
|
data/README.md
CHANGED
@@ -389,6 +389,17 @@ Soda.length # => 1
|
|
389
389
|
Soda.first.flavor # => sweet
|
390
390
|
Soda.first.price # => 1.0
|
391
391
|
```
|
392
|
+
|
393
|
+
### Using ERB ruby in YAML
|
394
|
+
|
395
|
+
Embedded ruby can bu used in ActiveYaml using erb brackets `<% %>` and `<%= %>` to set the result of a ruby operation as a value in the yaml file.
|
396
|
+
|
397
|
+
```
|
398
|
+
- id: 1
|
399
|
+
email: <%= "user#{rand(100)}@email.com" %>
|
400
|
+
password: <%= ENV['USER_PASSWORD'] %>
|
401
|
+
```
|
402
|
+
|
392
403
|
## ActiveJSON
|
393
404
|
|
394
405
|
If you want to store your data in JSON files, just inherit from ActiveJSON and specify your path information:
|
data/active_hash.gemspec
CHANGED
@@ -44,6 +44,6 @@ Gem::Specification.new do |s|
|
|
44
44
|
Dir.glob("lib/**/*")
|
45
45
|
].flatten
|
46
46
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
47
|
-
s.add_runtime_dependency('activesupport', '>=
|
48
|
-
s.required_ruby_version = '>=
|
47
|
+
s.add_runtime_dependency('activesupport', '>= 5.0.0')
|
48
|
+
s.required_ruby_version = '>= 2.4.0'
|
49
49
|
end
|
data/lib/active_hash/base.rb
CHANGED
data/lib/active_hash/version.rb
CHANGED
data/lib/active_yaml/base.rb
CHANGED
data/lib/enum/enum.rb
CHANGED
@@ -23,7 +23,7 @@ module ActiveHash
|
|
23
23
|
if @enum_accessors.present?
|
24
24
|
@records.each do |record|
|
25
25
|
constant = constant_for(record, @enum_accessors)
|
26
|
-
remove_const(constant) if const_defined?(constant)
|
26
|
+
remove_const(constant) if const_defined?(constant, false)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
super
|
@@ -33,10 +33,10 @@ module ActiveHash
|
|
33
33
|
constant = constant_for(record, @enum_accessors)
|
34
34
|
return nil if constant.blank?
|
35
35
|
|
36
|
-
unless const_defined?(constant)
|
36
|
+
unless const_defined?(constant, false)
|
37
37
|
const_set(constant, record)
|
38
38
|
else
|
39
|
-
raise DuplicateEnumAccessor, "#{constant} already defined for #{self.class}" unless const_get(constant) == record
|
39
|
+
raise DuplicateEnumAccessor, "#{constant} already defined for #{self.class}" unless const_get(constant, false) == record
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
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: 2.
|
4
|
+
version: 2.1.0
|
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: 2018-
|
32
|
+
date: 2018-04-05 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: activesupport
|
@@ -37,14 +37,14 @@ dependencies:
|
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 5.0.0
|
41
41
|
type: :runtime
|
42
42
|
prerelease: false
|
43
43
|
version_requirements: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 5.0.0
|
48
48
|
description: Includes the ability to specify data using hashes, yml files or JSON
|
49
49
|
files
|
50
50
|
email: jeff@zilkey.com
|
@@ -79,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 2.4.0
|
83
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
85
|
- - ">="
|