ostruct 0.5.0 → 0.5.1
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 +13 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cd7835b13bb18fa62b7db22bf42fbd57785c07b4a38ccad4a1b4449d2979133
|
4
|
+
data.tar.gz: b1fb70a803b08bbbaa0e07a12c6e2b0844743e1613a6c083abc4e35dbb005a59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1258b993e79b8feff50d4f8dfbbb1ce631421ff8ede98505dde0913d373e41dcca6005e543c2920e18849d8e0af641ac7fc215e61d96b578157619e125d1e9a4
|
7
|
+
data.tar.gz: 6a957da45dfa487e5d3673c44c621972d41a33508d9fc1af83f9b540498f777dba1a658d13f155ba413d36c055ea8c1e15e23dea80b5d8d715eb3178706824af
|
data/lib/ostruct.rb
CHANGED
@@ -93,21 +93,21 @@
|
|
93
93
|
# o.methods = [:foo, :bar]
|
94
94
|
# o.methods # => [:foo, :bar]
|
95
95
|
#
|
96
|
-
# To help remedy clashes, OpenStruct uses only protected/private methods ending with
|
97
|
-
# and defines aliases for builtin public methods by adding a
|
96
|
+
# To help remedy clashes, OpenStruct uses only protected/private methods ending with <code>!</code>
|
97
|
+
# and defines aliases for builtin public methods by adding a <code>!</code>:
|
98
98
|
#
|
99
99
|
# o = OpenStruct.new(make: 'Bentley', class: :luxury)
|
100
100
|
# o.class # => :luxury
|
101
101
|
# o.class! # => OpenStruct
|
102
102
|
#
|
103
|
-
# It is recommended (but not enforced) to not use fields ending in
|
103
|
+
# It is recommended (but not enforced) to not use fields ending in <code>!</code>;
|
104
104
|
# Note that a subclass' methods may not be overwritten, nor can OpenStruct's own methods
|
105
|
-
# ending with
|
105
|
+
# ending with <code>!</code>.
|
106
106
|
#
|
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.1"
|
111
111
|
|
112
112
|
#
|
113
113
|
# Creates a new OpenStruct object. By default, the resulting OpenStruct
|
@@ -279,7 +279,7 @@ class OpenStruct
|
|
279
279
|
# :call-seq:
|
280
280
|
# ostruct[name] -> object
|
281
281
|
#
|
282
|
-
# Returns the value of an attribute, or
|
282
|
+
# Returns the value of an attribute, or +nil+ if there is no such attribute.
|
283
283
|
#
|
284
284
|
# require "ostruct"
|
285
285
|
# person = OpenStruct.new("name" => "John Smith", "age" => 70)
|
@@ -452,8 +452,13 @@ class OpenStruct
|
|
452
452
|
update_to_values!(h)
|
453
453
|
end
|
454
454
|
|
455
|
-
# Make all public methods (builtin or our own) accessible with
|
456
|
-
|
455
|
+
# Make all public methods (builtin or our own) accessible with <code>!</code>:
|
456
|
+
give_access = instance_methods
|
457
|
+
# See https://github.com/ruby/ostruct/issues/30
|
458
|
+
give_access -= %i[instance_exec instance_eval eval] if RUBY_ENGINE == 'jruby'
|
459
|
+
give_access.each do |method|
|
460
|
+
next if method.match(/\W$/)
|
461
|
+
|
457
462
|
new_name = "#{method}!"
|
458
463
|
alias_method new_name, method
|
459
464
|
end
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc-Andre Lafortune
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-07 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.3
|
77
|
+
rubygems_version: 3.2.3
|
78
78
|
signing_key:
|
79
79
|
specification_version: 4
|
80
80
|
summary: Class to build custom data structures, similar to a Hash.
|