hashie 3.5.7 → 5.0.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 +5 -5
- data/CHANGELOG.md +281 -195
- data/CONTRIBUTING.md +13 -6
- data/LICENSE +1 -1
- data/README.md +320 -60
- data/Rakefile +2 -2
- data/UPGRADING.md +121 -7
- data/hashie.gemspec +13 -7
- data/lib/hashie/clash.rb +12 -1
- data/lib/hashie/dash.rb +56 -35
- data/lib/hashie/extensions/active_support/core_ext/hash.rb +14 -0
- data/lib/hashie/extensions/coercion.rb +26 -19
- data/lib/hashie/extensions/dash/indifferent_access.rb +29 -1
- data/lib/hashie/extensions/dash/predefined_values.rb +88 -0
- data/lib/hashie/extensions/dash/property_translation.rb +59 -28
- data/lib/hashie/extensions/deep_fetch.rb +5 -3
- data/lib/hashie/extensions/deep_find.rb +14 -5
- data/lib/hashie/extensions/deep_locate.rb +22 -8
- data/lib/hashie/extensions/deep_merge.rb +26 -10
- data/lib/hashie/extensions/ignore_undeclared.rb +4 -5
- data/lib/hashie/extensions/indifferent_access.rb +43 -10
- data/lib/hashie/extensions/key_conflict_warning.rb +55 -0
- data/lib/hashie/extensions/mash/define_accessors.rb +90 -0
- data/lib/hashie/extensions/mash/keep_original_keys.rb +4 -5
- data/lib/hashie/extensions/mash/permissive_respond_to.rb +61 -0
- data/lib/hashie/extensions/mash/safe_assignment.rb +3 -1
- data/lib/hashie/extensions/mash/symbolize_keys.rb +6 -6
- data/lib/hashie/extensions/method_access.rb +47 -14
- data/lib/hashie/extensions/parsers/yaml_erb_parser.rb +28 -4
- data/lib/hashie/extensions/ruby_version_check.rb +5 -1
- data/lib/hashie/extensions/strict_key_access.rb +16 -13
- data/lib/hashie/extensions/stringify_keys.rb +1 -1
- data/lib/hashie/extensions/symbolize_keys.rb +13 -2
- data/lib/hashie/hash.rb +18 -11
- data/lib/hashie/mash.rb +147 -81
- data/lib/hashie/railtie.rb +7 -0
- data/lib/hashie/rash.rb +6 -6
- data/lib/hashie/utils.rb +28 -0
- data/lib/hashie/version.rb +1 -1
- data/lib/hashie.rb +22 -19
- metadata +23 -131
- data/spec/hashie/array_spec.rb +0 -29
- data/spec/hashie/clash_spec.rb +0 -70
- data/spec/hashie/dash_spec.rb +0 -573
- data/spec/hashie/extensions/autoload_spec.rb +0 -24
- data/spec/hashie/extensions/coercion_spec.rb +0 -631
- data/spec/hashie/extensions/dash/coercion_spec.rb +0 -13
- data/spec/hashie/extensions/dash/indifferent_access_spec.rb +0 -84
- data/spec/hashie/extensions/deep_fetch_spec.rb +0 -97
- data/spec/hashie/extensions/deep_find_spec.rb +0 -138
- data/spec/hashie/extensions/deep_locate_spec.rb +0 -137
- data/spec/hashie/extensions/deep_merge_spec.rb +0 -70
- data/spec/hashie/extensions/ignore_undeclared_spec.rb +0 -47
- data/spec/hashie/extensions/indifferent_access_spec.rb +0 -282
- data/spec/hashie/extensions/indifferent_access_with_rails_hwia_spec.rb +0 -208
- data/spec/hashie/extensions/key_conversion_spec.rb +0 -12
- data/spec/hashie/extensions/mash/keep_original_keys_spec.rb +0 -46
- data/spec/hashie/extensions/mash/safe_assignment_spec.rb +0 -50
- data/spec/hashie/extensions/mash/symbolize_keys_spec.rb +0 -39
- data/spec/hashie/extensions/merge_initializer_spec.rb +0 -23
- data/spec/hashie/extensions/method_access_spec.rb +0 -188
- data/spec/hashie/extensions/strict_key_access_spec.rb +0 -110
- data/spec/hashie/extensions/stringify_keys_spec.rb +0 -124
- data/spec/hashie/extensions/symbolize_keys_spec.rb +0 -129
- data/spec/hashie/hash_spec.rb +0 -84
- data/spec/hashie/mash_spec.rb +0 -763
- data/spec/hashie/parsers/yaml_erb_parser_spec.rb +0 -46
- data/spec/hashie/rash_spec.rb +0 -83
- data/spec/hashie/trash_spec.rb +0 -268
- data/spec/hashie/utils_spec.rb +0 -25
- data/spec/hashie/version_spec.rb +0 -7
- data/spec/hashie_spec.rb +0 -13
- data/spec/integration/omniauth/app.rb +0 -11
- data/spec/integration/omniauth/integration_spec.rb +0 -38
- data/spec/integration/omniauth-oauth2/app.rb +0 -53
- data/spec/integration/omniauth-oauth2/integration_spec.rb +0 -26
- data/spec/integration/omniauth-oauth2/some_site.rb +0 -38
- data/spec/integration/rails/app.rb +0 -48
- data/spec/integration/rails/integration_spec.rb +0 -26
- data/spec/integration/rails-without-dependency/integration_spec.rb +0 -15
- data/spec/spec_helper.rb +0 -23
- data/spec/support/integration_specs.rb +0 -36
- data/spec/support/logger.rb +0 -24
- data/spec/support/module_context.rb +0 -11
- data/spec/support/ruby_version_check.rb +0 -6
data/lib/hashie/mash.rb
CHANGED
@@ -2,6 +2,7 @@ require 'hashie/hash'
|
|
2
2
|
require 'hashie/array'
|
3
3
|
require 'hashie/utils'
|
4
4
|
require 'hashie/logger'
|
5
|
+
require 'hashie/extensions/key_conflict_warning'
|
5
6
|
|
6
7
|
module Hashie
|
7
8
|
# Mash allows you to create pseudo-objects that have method-like
|
@@ -15,9 +16,12 @@ module Hashie
|
|
15
16
|
#
|
16
17
|
# * No punctuation: Returns the value of the hash for that key, or nil if none exists.
|
17
18
|
# * Assignment (<tt>=</tt>): Sets the attribute of the given method name.
|
18
|
-
# *
|
19
|
-
#
|
20
|
-
# *
|
19
|
+
# * Truthiness (<tt>?</tt>): Returns true or false depending on the truthiness of
|
20
|
+
# the attribute, or false if the key is not set.
|
21
|
+
# * Bang (<tt>!</tt>): Forces the existence of this key, used for deep Mashes. Think of it
|
22
|
+
# as "touch" for mashes.
|
23
|
+
# * Under Bang (<tt>_</tt>): Like Bang, but returns a new Mash rather than creating a key.
|
24
|
+
# Used to test existance in deep Mashes.
|
21
25
|
#
|
22
26
|
# == Basic Example
|
23
27
|
#
|
@@ -58,51 +62,20 @@ module Hashie
|
|
58
62
|
# mash.author # => <Mash>
|
59
63
|
#
|
60
64
|
class Mash < Hash
|
61
|
-
include Hashie::Extensions::PrettyInspect
|
62
65
|
include Hashie::Extensions::RubyVersionCheck
|
66
|
+
extend Hashie::Extensions::KeyConflictWarning
|
63
67
|
|
64
|
-
ALLOWED_SUFFIXES = %w
|
65
|
-
|
66
|
-
class CannotDisableMashWarnings < StandardError
|
67
|
-
def initialize(message = 'You cannot disable warnings on the base Mash class. Please subclass the Mash and disable it in the subclass.')
|
68
|
-
super(message)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
# Disable the logging of warnings based on keys conflicting keys/methods
|
73
|
-
#
|
74
|
-
# @api semipublic
|
75
|
-
# @return [void]
|
76
|
-
def self.disable_warnings
|
77
|
-
fail CannotDisableMashWarnings if self == Hashie::Mash
|
78
|
-
@disable_warnings = true
|
79
|
-
end
|
80
|
-
|
81
|
-
# Checks whether this class disables warnings for conflicting keys/methods
|
82
|
-
#
|
83
|
-
# @api semipublic
|
84
|
-
# @return [Boolean]
|
85
|
-
def self.disable_warnings?
|
86
|
-
@disable_warnings ||= false
|
87
|
-
end
|
88
|
-
|
89
|
-
# Inheritance hook that sets class configuration when inherited.
|
90
|
-
#
|
91
|
-
# @api semipublic
|
92
|
-
# @return [void]
|
93
|
-
def self.inherited(subclass)
|
94
|
-
super
|
95
|
-
subclass.disable_warnings if disable_warnings?
|
96
|
-
end
|
68
|
+
ALLOWED_SUFFIXES = %w[? ! = _].freeze
|
97
69
|
|
98
70
|
def self.load(path, options = {})
|
99
71
|
@_mashes ||= new
|
100
72
|
|
101
73
|
return @_mashes[path] if @_mashes.key?(path)
|
102
|
-
|
74
|
+
raise ArgumentError, "The following file doesn't exist: #{path}" unless File.file?(path)
|
103
75
|
|
104
|
-
|
105
|
-
|
76
|
+
options = options.dup
|
77
|
+
parser = options.delete(:parser) { Hashie::Extensions::Parsers::YamlErbParser }
|
78
|
+
@_mashes[path] = new(parser.perform(path, options)).freeze
|
106
79
|
end
|
107
80
|
|
108
81
|
def to_module(mash_method_name = :settings)
|
@@ -114,7 +87,11 @@ module Hashie
|
|
114
87
|
end
|
115
88
|
end
|
116
89
|
|
117
|
-
|
90
|
+
def with_accessors!
|
91
|
+
extend Hashie::Extensions::Mash::DefineAccessors
|
92
|
+
end
|
93
|
+
|
94
|
+
alias to_s inspect
|
118
95
|
|
119
96
|
# If you pass in an existing hash, it will
|
120
97
|
# convert it to a Mash including recursively
|
@@ -125,13 +102,26 @@ module Hashie
|
|
125
102
|
default ? super(default) : super(&blk)
|
126
103
|
end
|
127
104
|
|
128
|
-
|
105
|
+
# Creates a new anonymous subclass with key conflict
|
106
|
+
# warnings disabled. You may pass an array of method
|
107
|
+
# symbols to restrict the disabled warnings to.
|
108
|
+
# Hashie::Mash.quiet.new(hash) all warnings disabled.
|
109
|
+
# Hashie::Mash.quiet(:zip).new(hash) only zip warning
|
110
|
+
# is disabled.
|
111
|
+
def self.quiet(*method_keys)
|
112
|
+
@memoized_classes ||= {}
|
113
|
+
@memoized_classes[method_keys] ||= Class.new(self) do
|
114
|
+
disable_warnings(*method_keys)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
class << self; alias [] new; end
|
129
119
|
|
130
|
-
|
131
|
-
|
120
|
+
alias regular_reader []
|
121
|
+
alias regular_writer []=
|
132
122
|
|
133
|
-
# Retrieves an attribute set in the Mash. Will convert
|
134
|
-
#
|
123
|
+
# Retrieves an attribute set in the Mash. Will convert a key passed in
|
124
|
+
# as a symbol to a string before retrieving.
|
135
125
|
def custom_reader(key)
|
136
126
|
default_proc.call(self, key) if default_proc && !key?(key)
|
137
127
|
value = regular_reader(convert_key(key))
|
@@ -139,18 +129,16 @@ module Hashie
|
|
139
129
|
value
|
140
130
|
end
|
141
131
|
|
142
|
-
# Sets an attribute in the Mash.
|
143
|
-
#
|
144
|
-
#
|
132
|
+
# Sets an attribute in the Mash. Symbol keys will be converted to
|
133
|
+
# strings before being set, and Hashes will be converted into Mashes
|
134
|
+
# for nesting purposes.
|
145
135
|
def custom_writer(key, value, convert = true) #:nodoc:
|
146
|
-
|
147
|
-
|
148
|
-
log_built_in_message(key_as_symbol) if log_collision?(key_as_symbol)
|
149
|
-
regular_writer(key, convert ? convert_value(value) : value)
|
136
|
+
log_built_in_message(key) if key.respond_to?(:to_sym) && log_collision?(key.to_sym)
|
137
|
+
regular_writer(convert_key(key), convert ? convert_value(value) : value)
|
150
138
|
end
|
151
139
|
|
152
|
-
|
153
|
-
|
140
|
+
alias [] custom_reader
|
141
|
+
alias []= custom_writer
|
154
142
|
|
155
143
|
# This is the bang method reader, it will return a new Mash
|
156
144
|
# if there isn't a value already assigned to the key requested.
|
@@ -183,45 +171,89 @@ module Hashie
|
|
183
171
|
super(*keys.map { |key| convert_key(key) })
|
184
172
|
end
|
185
173
|
|
186
|
-
|
174
|
+
# Returns a new instance of the class it was called on, using its keys as
|
175
|
+
# values, and its values as keys. The new values and keys will always be
|
176
|
+
# strings.
|
177
|
+
def invert
|
178
|
+
self.class.new(super)
|
179
|
+
end
|
180
|
+
|
181
|
+
# Returns a new instance of the class it was called on, containing elements
|
182
|
+
# for which the given block returns false.
|
183
|
+
def reject(&blk)
|
184
|
+
self.class.new(super(&blk))
|
185
|
+
end
|
186
|
+
|
187
|
+
# Returns a new instance of the class it was called on, containing elements
|
188
|
+
# for which the given block returns true.
|
189
|
+
def select(&blk)
|
190
|
+
self.class.new(super(&blk))
|
191
|
+
end
|
192
|
+
|
193
|
+
alias regular_dup dup
|
187
194
|
# Duplicates the current mash as a new mash.
|
188
195
|
def dup
|
189
|
-
self.class.new(self, default)
|
196
|
+
self.class.new(self, default, &default_proc)
|
190
197
|
end
|
191
198
|
|
192
|
-
|
199
|
+
alias regular_key? key?
|
193
200
|
def key?(key)
|
194
201
|
super(convert_key(key))
|
195
202
|
end
|
196
|
-
|
197
|
-
|
198
|
-
|
203
|
+
alias has_key? key?
|
204
|
+
alias include? key?
|
205
|
+
alias member? key?
|
206
|
+
|
207
|
+
if with_minimum_ruby?('2.6.0')
|
208
|
+
# Performs a deep_update on a duplicate of the
|
209
|
+
# current mash.
|
210
|
+
def deep_merge(*other_hashes, &blk)
|
211
|
+
dup.deep_update(*other_hashes, &blk)
|
212
|
+
end
|
199
213
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
214
|
+
# Recursively merges this mash with the passed
|
215
|
+
# in hash, merging each hash in the hierarchy.
|
216
|
+
def deep_update(*other_hashes, &blk)
|
217
|
+
other_hashes.each do |other_hash|
|
218
|
+
_deep_update(other_hash, &blk)
|
219
|
+
end
|
220
|
+
self
|
221
|
+
end
|
222
|
+
else
|
223
|
+
# Performs a deep_update on a duplicate of the
|
224
|
+
# current mash.
|
225
|
+
def deep_merge(other_hash, &blk)
|
226
|
+
dup.deep_update(other_hash, &blk)
|
227
|
+
end
|
228
|
+
|
229
|
+
# Recursively merges this mash with the passed
|
230
|
+
# in hash, merging each hash in the hierarchy.
|
231
|
+
def deep_update(other_hash, &blk)
|
232
|
+
_deep_update(other_hash, &blk)
|
233
|
+
self
|
234
|
+
end
|
204
235
|
end
|
205
|
-
alias_method :merge, :deep_merge
|
206
236
|
|
207
|
-
#
|
208
|
-
#
|
209
|
-
|
237
|
+
# Alias these lexically so they get the correctly defined
|
238
|
+
# #deep_merge and #deep_update based on ruby version.
|
239
|
+
alias merge deep_merge
|
240
|
+
alias deep_merge! deep_update
|
241
|
+
alias update deep_update
|
242
|
+
alias merge! update
|
243
|
+
|
244
|
+
def _deep_update(other_hash, &blk)
|
210
245
|
other_hash.each_pair do |k, v|
|
211
246
|
key = convert_key(k)
|
212
|
-
if
|
247
|
+
if v.is_a?(::Hash) && key?(key) && regular_reader(key).is_a?(Mash)
|
213
248
|
custom_reader(key).deep_update(v, &blk)
|
214
249
|
else
|
215
250
|
value = convert_value(v, true)
|
216
|
-
value = convert_value(
|
251
|
+
value = convert_value(yield(key, self[k], value), true) if blk && key?(k)
|
217
252
|
custom_writer(key, value, false)
|
218
253
|
end
|
219
254
|
end
|
220
|
-
self
|
221
255
|
end
|
222
|
-
|
223
|
-
alias_method :update, :deep_update
|
224
|
-
alias_method :merge!, :update
|
256
|
+
private :_deep_update
|
225
257
|
|
226
258
|
# Assigns a value to a key
|
227
259
|
def assign_property(name, value)
|
@@ -263,7 +295,7 @@ module Hashie
|
|
263
295
|
method_name.end_with?(*ALLOWED_SUFFIXES) && key?(method_name.chop)
|
264
296
|
end
|
265
297
|
|
266
|
-
def method_missing(method_name, *args, &blk)
|
298
|
+
def method_missing(method_name, *args, &blk) # rubocop:disable Style/MethodMissing
|
267
299
|
return self.[](method_name, &blk) if key?(method_name)
|
268
300
|
name, suffix = method_name_and_suffix(method_name)
|
269
301
|
case suffix
|
@@ -296,6 +328,36 @@ module Hashie
|
|
296
328
|
end
|
297
329
|
end
|
298
330
|
|
331
|
+
with_minimum_ruby('2.4.0') do
|
332
|
+
def transform_values(&blk)
|
333
|
+
self.class.new(super(&blk))
|
334
|
+
end
|
335
|
+
|
336
|
+
# Returns a new instance of the class it was called on, with nil values
|
337
|
+
# removed.
|
338
|
+
def compact
|
339
|
+
self.class.new(super)
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
with_minimum_ruby('2.5.0') do
|
344
|
+
def slice(*keys)
|
345
|
+
string_keys = keys.map { |key| convert_key(key) }
|
346
|
+
self.class.new(super(*string_keys))
|
347
|
+
end
|
348
|
+
|
349
|
+
def transform_keys(&blk)
|
350
|
+
self.class.new(super(&blk))
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
with_minimum_ruby('3.0.0') do
|
355
|
+
def except(*keys)
|
356
|
+
string_keys = keys.map { |key| convert_key(key) }
|
357
|
+
self.class.new(super(*string_keys))
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
299
361
|
protected
|
300
362
|
|
301
363
|
def method_name_and_suffix(method_name)
|
@@ -313,7 +375,7 @@ module Hashie
|
|
313
375
|
end
|
314
376
|
|
315
377
|
def convert_key(key) #:nodoc:
|
316
|
-
key.to_s
|
378
|
+
key.respond_to?(:to_sym) ? key.to_s : key
|
317
379
|
end
|
318
380
|
|
319
381
|
def convert_value(val, duping = false) #:nodoc:
|
@@ -325,8 +387,6 @@ module Hashie
|
|
325
387
|
when ::Hash
|
326
388
|
val = val.dup if duping
|
327
389
|
self.class.new(val)
|
328
|
-
when Array
|
329
|
-
val.map { |e| convert_value(e) }
|
330
390
|
when ::Array
|
331
391
|
Array.new(val.map { |e| convert_value(e) })
|
332
392
|
else
|
@@ -337,7 +397,7 @@ module Hashie
|
|
337
397
|
private
|
338
398
|
|
339
399
|
def log_built_in_message(method_key)
|
340
|
-
return if self.class.disable_warnings?
|
400
|
+
return if self.class.disable_warnings?(method_key)
|
341
401
|
|
342
402
|
method_information = Hashie::Utils.method_information(method(method_key))
|
343
403
|
|
@@ -350,7 +410,13 @@ module Hashie
|
|
350
410
|
end
|
351
411
|
|
352
412
|
def log_collision?(method_key)
|
353
|
-
|
413
|
+
return unless method_key.is_a?(String) || method_key.is_a?(Symbol)
|
414
|
+
return unless respond_to?(method_key)
|
415
|
+
|
416
|
+
_, suffix = method_name_and_suffix(method_key)
|
417
|
+
|
418
|
+
(!suffix || suffix == '='.freeze) &&
|
419
|
+
!self.class.disable_warnings?(method_key) &&
|
354
420
|
!(regular_key?(method_key) || regular_key?(method_key.to_s))
|
355
421
|
end
|
356
422
|
end
|
data/lib/hashie/railtie.rb
CHANGED
@@ -7,6 +7,13 @@ begin
|
|
7
7
|
initializer 'hashie.configure_logger', after: 'initialize_logger' do
|
8
8
|
Hashie.logger = Rails.logger
|
9
9
|
end
|
10
|
+
|
11
|
+
initializer 'hashie.patch_hash_except', after: 'load_active_support' do
|
12
|
+
if Rails::VERSION::MAJOR >= 6
|
13
|
+
require 'hashie/extensions/active_support/core_ext/hash'
|
14
|
+
Hashie::Mash.send(:include, Hashie::Extensions::ActiveSupport::CoreExt::Hash)
|
15
|
+
end
|
16
|
+
end
|
10
17
|
end
|
11
18
|
end
|
12
19
|
rescue LoadError => e
|
data/lib/hashie/rash.rb
CHANGED
@@ -64,7 +64,7 @@ module Hashie
|
|
64
64
|
# Raise (or yield) unless something matches the key.
|
65
65
|
#
|
66
66
|
def fetch(*args)
|
67
|
-
|
67
|
+
raise ArgumentError, "Expected 1-2 arguments, got #{args.length}" \
|
68
68
|
unless (1..2).cover?(args.length)
|
69
69
|
|
70
70
|
key, default = args
|
@@ -78,7 +78,7 @@ module Hashie
|
|
78
78
|
elsif default
|
79
79
|
default
|
80
80
|
else
|
81
|
-
|
81
|
+
raise KeyError, "key not found: #{key.inspect}"
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -117,7 +117,7 @@ module Hashie
|
|
117
117
|
end
|
118
118
|
|
119
119
|
when Regexp
|
120
|
-
# Reverse operation: `rash[/regexp/]` returns all
|
120
|
+
# Reverse operation: `rash[/regexp/]` returns all string keys matching the regexp
|
121
121
|
@hash.each do |key, val|
|
122
122
|
yield val if key.is_a?(String) && query =~ key
|
123
123
|
end
|
@@ -125,11 +125,11 @@ module Hashie
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def method_missing(*args, &block)
|
128
|
-
@hash.send(*args, &block)
|
128
|
+
@hash.send(*args, &block) || super
|
129
129
|
end
|
130
130
|
|
131
|
-
def respond_to_missing?(
|
132
|
-
@hash.respond_to?(
|
131
|
+
def respond_to_missing?(method_name, _include_private = false)
|
132
|
+
@hash.respond_to?(method_name)
|
133
133
|
end
|
134
134
|
|
135
135
|
private
|
data/lib/hashie/utils.rb
CHANGED
@@ -12,5 +12,33 @@ module Hashie
|
|
12
12
|
"defined in #{bound_method.owner}"
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
# Duplicates a value or returns the value when it is not duplicable
|
17
|
+
#
|
18
|
+
# @api public
|
19
|
+
#
|
20
|
+
# @param value [Object] the value to safely duplicate
|
21
|
+
# @return [Object] the duplicated value
|
22
|
+
def self.safe_dup(value)
|
23
|
+
case value
|
24
|
+
when Complex, FalseClass, NilClass, Rational, Method, Symbol, TrueClass, *integer_classes
|
25
|
+
value
|
26
|
+
else
|
27
|
+
value.dup
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Lists the classes Ruby uses for integers
|
32
|
+
#
|
33
|
+
# @api private
|
34
|
+
# @return [Array<Class>]
|
35
|
+
def self.integer_classes
|
36
|
+
@integer_classes ||=
|
37
|
+
if 0.class == Integer
|
38
|
+
[Integer]
|
39
|
+
else
|
40
|
+
[Fixnum, Bignum] # rubocop:disable Lint/UnifiedInteger
|
41
|
+
end
|
42
|
+
end
|
15
43
|
end
|
16
44
|
end
|
data/lib/hashie/version.rb
CHANGED
data/lib/hashie.rb
CHANGED
@@ -12,26 +12,26 @@ module Hashie
|
|
12
12
|
autoload :Utils, 'hashie/utils'
|
13
13
|
|
14
14
|
module Extensions
|
15
|
-
autoload :Coercion,
|
16
|
-
autoload :DeepMerge,
|
17
|
-
autoload :IgnoreUndeclared,
|
18
|
-
autoload :IndifferentAccess,
|
19
|
-
autoload :MergeInitializer,
|
20
|
-
autoload :MethodAccess,
|
21
|
-
autoload :MethodQuery,
|
22
|
-
autoload :MethodReader,
|
23
|
-
autoload :MethodWriter,
|
24
|
-
autoload :StringifyKeys,
|
25
|
-
autoload :SymbolizeKeys,
|
26
|
-
autoload :DeepFetch,
|
27
|
-
autoload :DeepFind,
|
28
|
-
autoload :DeepLocate,
|
29
|
-
autoload :PrettyInspect,
|
30
|
-
autoload :KeyConversion,
|
15
|
+
autoload :Coercion, 'hashie/extensions/coercion'
|
16
|
+
autoload :DeepMerge, 'hashie/extensions/deep_merge'
|
17
|
+
autoload :IgnoreUndeclared, 'hashie/extensions/ignore_undeclared'
|
18
|
+
autoload :IndifferentAccess, 'hashie/extensions/indifferent_access'
|
19
|
+
autoload :MergeInitializer, 'hashie/extensions/merge_initializer'
|
20
|
+
autoload :MethodAccess, 'hashie/extensions/method_access'
|
21
|
+
autoload :MethodQuery, 'hashie/extensions/method_access'
|
22
|
+
autoload :MethodReader, 'hashie/extensions/method_access'
|
23
|
+
autoload :MethodWriter, 'hashie/extensions/method_access'
|
24
|
+
autoload :StringifyKeys, 'hashie/extensions/stringify_keys'
|
25
|
+
autoload :SymbolizeKeys, 'hashie/extensions/symbolize_keys'
|
26
|
+
autoload :DeepFetch, 'hashie/extensions/deep_fetch'
|
27
|
+
autoload :DeepFind, 'hashie/extensions/deep_find'
|
28
|
+
autoload :DeepLocate, 'hashie/extensions/deep_locate'
|
29
|
+
autoload :PrettyInspect, 'hashie/extensions/pretty_inspect'
|
30
|
+
autoload :KeyConversion, 'hashie/extensions/key_conversion'
|
31
31
|
autoload :MethodAccessWithOverride, 'hashie/extensions/method_access'
|
32
|
-
autoload :StrictKeyAccess,
|
33
|
-
autoload :RubyVersion,
|
34
|
-
autoload :RubyVersionCheck,
|
32
|
+
autoload :StrictKeyAccess, 'hashie/extensions/strict_key_access'
|
33
|
+
autoload :RubyVersion, 'hashie/extensions/ruby_version'
|
34
|
+
autoload :RubyVersionCheck, 'hashie/extensions/ruby_version_check'
|
35
35
|
|
36
36
|
module Parsers
|
37
37
|
autoload :YamlErbParser, 'hashie/extensions/parsers/yaml_erb_parser'
|
@@ -41,12 +41,15 @@ module Hashie
|
|
41
41
|
autoload :IndifferentAccess, 'hashie/extensions/dash/indifferent_access'
|
42
42
|
autoload :PropertyTranslation, 'hashie/extensions/dash/property_translation'
|
43
43
|
autoload :Coercion, 'hashie/extensions/dash/coercion'
|
44
|
+
autoload :PredefinedValues, 'hashie/extensions/dash/predefined_values'
|
44
45
|
end
|
45
46
|
|
46
47
|
module Mash
|
47
48
|
autoload :KeepOriginalKeys, 'hashie/extensions/mash/keep_original_keys'
|
49
|
+
autoload :PermissiveRespondTo, 'hashie/extensions/mash/permissive_respond_to'
|
48
50
|
autoload :SafeAssignment, 'hashie/extensions/mash/safe_assignment'
|
49
51
|
autoload :SymbolizeKeys, 'hashie/extensions/mash/symbolize_keys'
|
52
|
+
autoload :DefineAccessors, 'hashie/extensions/mash/define_accessors'
|
50
53
|
end
|
51
54
|
|
52
55
|
module Array
|