active_hash 2.0.0 → 2.1.0

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
  SHA256:
3
- metadata.gz: 475fb352ab35cf436d135d74983e6ca7115c24a15d12681dd1176af36cea8cea
4
- data.tar.gz: 98d31cd371ae7363e0c8e32ab7e7d87a3e2c74f1d4621456e17448be016a8c01
3
+ metadata.gz: 5a92e60195ef8ad5fbd50981978f78755d5f670ba04dd3b97604454e9c466e14
4
+ data.tar.gz: a00b0870924b1cc46e5f0fc63a75847bcd54532f4f6e8c9c0367c7058ec079e1
5
5
  SHA512:
6
- metadata.gz: a9731e071b74c51753692d5e9d96144645cb314915ee8537666f1185fc23be109e3747c92bcbd68bcb429b9bf9564788694fb726d804ddb69354f0bcd93150a8
7
- data.tar.gz: ce8d0eb87fea1909091dd01fc2f2afc20434f0fa22223777351880c6c8753fd4609d0784a001cfd1bfe194ed9a31d53bd24a49e867ece3b30545ffdec67b38d1
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:
@@ -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', '>= 2.2.2')
48
- s.required_ruby_version = '>= 1.9.3'
47
+ s.add_runtime_dependency('activesupport', '>= 5.0.0')
48
+ s.required_ruby_version = '>= 2.4.0'
49
49
  end
@@ -397,6 +397,11 @@ module ActiveHash
397
397
  ActiveHash::Base
398
398
  end
399
399
 
400
+ # Needed for ActiveRecord polymorphic associations(rails/rails#32148)
401
+ def polymorphic_name
402
+ base_class.name
403
+ end
404
+
400
405
  def reload
401
406
  reset_record_index
402
407
  self.data = _data
@@ -1,5 +1,5 @@
1
1
  module ActiveHash
2
2
  module Gem
3
- VERSION = "2.0.0"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
@@ -19,7 +19,7 @@ module ActiveYaml
19
19
 
20
20
  private
21
21
  def load_path(path)
22
- YAML.load_file(path)
22
+ YAML.load(ERB.new(File.read(path)).result)
23
23
  end
24
24
  end
25
25
  end
@@ -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.0.0
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-02-27 00:00:00.000000000 Z
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: 2.2.2
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: 2.2.2
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: 1.9.3
82
+ version: 2.4.0
83
83
  required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  requirements:
85
85
  - - ">="