config_default 0.1.1 → 0.1.2

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: 8986cd898691eacd74aec36524a3eacd38433629b6ba8e71638619b33dd9f817
4
- data.tar.gz: 87e0031a77052c3f9e42b87a2c670874cca926a6e1d0803c0c9c113d717f441f
3
+ metadata.gz: e7e18b5eb5ba11e06e39b8ecc08aa74d98a32dc0bfe36caa787978224f1aca90
4
+ data.tar.gz: fee80751ea9a44bda3acbbb29d9714f287c6055f6c52c241251d7d8b42440df0
5
5
  SHA512:
6
- metadata.gz: f86e0e505bea0492833852ef4957c73ed8b3ab1b1f43e81e114cce90923fe737fb457ddf0259c5234a079b5458e6b1a6325c4dd560d2ad9c64526c63894bb432
7
- data.tar.gz: 68a825fe3fd12616f413d28a20b712b9d8783d18bbc3b88615999502581fcbb58a3f74b714149c7d07ea627a8f721f9f8ff4ade4026a7fe7cf8eed7a7ef1800f
6
+ metadata.gz: d6da506d9904ebaf20ffd47fb3d9e0aeef689fa3bb0e39950670f7ecc2fc24f22baf064ab38b23ab7f1ed5a88a6286a6d2aba0abd22291e84229a2f905d92f28
7
+ data.tar.gz: 444e8ddfdcee3d3ba48bbe8e3b19b83fde496cc9429b68d8df973de971f6994106d6b2dde311f795f02da2a8d0ef7a743a0ae07ccc25e651ccdf1cf5b4334df8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.2
2
+
3
+ - Move config struct option definition from `#method_missing` to `#define_singleton_method`
4
+
1
5
  ## 0.1.1
2
6
 
3
7
  - Remove Rails dependency.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- config_default (0.1.1)
4
+ config_default (0.1.2)
5
5
  activesupport (~> 6)
6
6
 
7
7
  GEM
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ConfigDefault::Struct
4
+ RESERVED_METHODS = %i[method_missing respond_to_missing? to_hash].freeze
5
+
4
6
  def initialize(attributes = {}, recursive: false, allow_nil: false)
5
7
  @attributes = ActiveSupport::HashWithIndifferentAccess.new(attributes)
6
8
  @allow_nil = allow_nil
@@ -13,6 +15,11 @@ class ConfigDefault::Struct
13
15
  end
14
16
  end
15
17
 
18
+ @attributes.each do |key, value|
19
+ next if RESERVED_METHODS.include?(key.to_sym)
20
+ define_singleton_method(key) { value }
21
+ end
22
+
16
23
  @attributes.freeze
17
24
  end
18
25
 
@@ -21,7 +28,6 @@ class ConfigDefault::Struct
21
28
  end
22
29
 
23
30
  def method_missing(method, *_args)
24
- return @attributes[method] if @attributes.key?(method)
25
31
  raise StandardError.new("There is no option :#{method} in configuration.") unless @allow_nil
26
32
  end
27
33
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ConfigDefault
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config_default
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stepan Kirushkin