ostruct 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ostruct.rb +13 -8
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21e6b4898eb983f5662872ec9b061babc748c196756225e561a2606f1be43f92
4
- data.tar.gz: ed5975f18423c5db6e0cc0262ce17aa8a625a9488ab8a3a0a556287e71e7881d
3
+ metadata.gz: 2cd7835b13bb18fa62b7db22bf42fbd57785c07b4a38ccad4a1b4449d2979133
4
+ data.tar.gz: b1fb70a803b08bbbaa0e07a12c6e2b0844743e1613a6c083abc4e35dbb005a59
5
5
  SHA512:
6
- metadata.gz: d1993c5247e4d0aa91ef62d1cdc943eb7e95b18a74abc0c6739c611ee4676c32a792801bb7b5f2f51c9992799863a5a6aeee66ad7ed69dd0f5b5b6ee0e227a2b
7
- data.tar.gz: 119f99ac4213fe46116ffba0c142af7cbba91c7b7e7273ff4fd154585df5f31aa2fdc0048fd4dddc8de21e4ab3e95e1214da40fbb2608126a795f83a2162c628
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.0"
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 `nil` if there is no such attribute.
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
- instance_methods.each do |method|
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.0
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-10-21 00:00:00.000000000 Z
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.0.dev
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.