ostruct 0.5.2 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ostruct.rb +12 -7
- data/ostruct.gemspec +0 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 860c3132a16e7c7e90c96f7241accad8d7f2e9e5a355fce61a2f15a3fc00943e
|
4
|
+
data.tar.gz: '068a9d69d71d7fdc75b69c11eae85f6ceb70212c59185307101076c748ba7344'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63155bc6c512c8ea516eb97c44088a2236c2e040837efdb609598f0e733542cb67883a21d77a0c35ad061617a2db8141fb84e9a69ffe7b1c9bbc4b341012c02e
|
7
|
+
data.tar.gz: 7cc37e85d8956426e0f89ac6f26da12d503faf40c6cc81c4743c6df6da8b9b08d56fd1cb6961b1fca4eb0700c73edc1e4f20c04c0dfbe8ceb5832f79fdefacd7
|
data/lib/ostruct.rb
CHANGED
@@ -107,7 +107,7 @@
|
|
107
107
|
# For all these reasons, consider not using OpenStruct at all.
|
108
108
|
#
|
109
109
|
class OpenStruct
|
110
|
-
VERSION = "0.5.
|
110
|
+
VERSION = "0.5.5"
|
111
111
|
|
112
112
|
#
|
113
113
|
# Creates a new OpenStruct object. By default, the resulting OpenStruct
|
@@ -197,7 +197,7 @@ class OpenStruct
|
|
197
197
|
# data.each_pair.to_a # => [[:country, "Australia"], [:capital, "Canberra"]]
|
198
198
|
#
|
199
199
|
def each_pair
|
200
|
-
return to_enum(__method__) { @table.size } unless
|
200
|
+
return to_enum(__method__) { @table.size } unless defined?(yield)
|
201
201
|
@table.each_pair{|p| yield p}
|
202
202
|
self
|
203
203
|
end
|
@@ -246,7 +246,7 @@ class OpenStruct
|
|
246
246
|
if owner.class == ::Class
|
247
247
|
owner < ::OpenStruct
|
248
248
|
else
|
249
|
-
self.class
|
249
|
+
self.class!.ancestors.any? do |mod|
|
250
250
|
return false if mod == ::OpenStruct
|
251
251
|
mod == owner
|
252
252
|
end
|
@@ -356,14 +356,14 @@ class OpenStruct
|
|
356
356
|
#
|
357
357
|
# person.delete_field('number') { 8675_309 } # => 8675309
|
358
358
|
#
|
359
|
-
def delete_field(name)
|
359
|
+
def delete_field(name, &block)
|
360
360
|
sym = name.to_sym
|
361
361
|
begin
|
362
362
|
singleton_class.remove_method(sym, "#{sym}=")
|
363
363
|
rescue NameError
|
364
364
|
end
|
365
365
|
@table.delete(sym) do
|
366
|
-
return yield if
|
366
|
+
return yield if block
|
367
367
|
raise! NameError.new("no field `#{sym}' in #{self}", sym)
|
368
368
|
end
|
369
369
|
end
|
@@ -467,6 +467,11 @@ class OpenStruct
|
|
467
467
|
end
|
468
468
|
# Other builtin private methods we use:
|
469
469
|
alias_method :raise!, :raise
|
470
|
-
|
471
|
-
|
470
|
+
private :raise!
|
471
|
+
|
472
|
+
# See https://github.com/ruby/ostruct/issues/40
|
473
|
+
if RUBY_ENGINE != 'jruby'
|
474
|
+
alias_method :block_given!, :block_given?
|
475
|
+
private :block_given!
|
476
|
+
end
|
472
477
|
end
|
data/ostruct.gemspec
CHANGED
@@ -20,8 +20,6 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.required_ruby_version = ">= 2.5.0"
|
21
21
|
|
22
22
|
spec.files = [".gitignore", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/ostruct.rb", "ostruct.gemspec"]
|
23
|
-
spec.bindir = "exe"
|
24
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
23
|
spec.require_paths = ["lib"]
|
26
24
|
|
27
25
|
spec.add_development_dependency "bundler"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ostruct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc-Andre Lafortune
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
|
-
rubygems_version: 3.
|
77
|
+
rubygems_version: 3.3.3
|
78
78
|
signing_key:
|
79
79
|
specification_version: 4
|
80
80
|
summary: Class to build custom data structures, similar to a Hash.
|