polyfill-data 1.0.4 → 1.0.5

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: 62f13af5e73dbe544ce73a294748dee539285c7f8405ec7e68f4d2187b51364c
4
- data.tar.gz: 0d4c325885a85e5ced977b50e38af25d44508d6c85a7d6e02f512a9e56d2dff8
3
+ metadata.gz: 159535856d8a85a17e4a90dff438911c7e3a04fcff60b1a016662f97e2575e68
4
+ data.tar.gz: c83127bfa5a28bd26dccfcdfbe0b095236136635c3180720cab55912a2fa9796
5
5
  SHA512:
6
- metadata.gz: 73f956793df2920f6c13d564d56592c72a19327ed9451dd536c3f69a8057038775e5a02e1ec8962f85c135d588b0d54df8f337297eaf18f992e6d29ce910d6de
7
- data.tar.gz: 25d0e20f500b2715c2ec352f8f2a46150832e40a9482f782450b2e0b2ebe3d9c6f78cafa19fc978b8fa78569771d22d10626b423ba71e555aa05f42112d38d03
6
+ metadata.gz: 2527a6f9e79192cf29d798ee4eb34059e1562690d9b9e8afd921a421b816cefe6f888273d29f6d186a42f459d35217b5639e8eca505235d72c35434fcaa07177
7
+ data.tar.gz: f3a3fe35c950d650a13831df4fb6eabe97eac73b6dd2f55ad518a12180d74202a30492c0fad50caa854dea57d9534bf9d60c9658be0f996f752632dd694c84e7
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 1.0.5
9
+
10
+ ### Fixed
11
+
12
+ - member methods take precedence over methods defined in the block passed to `define`
13
+
8
14
  ## 1.0.4
9
15
 
10
16
  ### Fixed
data/lib/data.rb CHANGED
@@ -14,7 +14,14 @@ else
14
14
 
15
15
  def self.define(*args, &block)
16
16
  raise ArgumentError if args.any?(/=/)
17
- klass = ::Class.new(self, &block)
17
+ if block
18
+ mod = Module.new
19
+ mod.define_singleton_method(:_,) do |klass|
20
+ klass.class_eval(&block)
21
+ end
22
+ arity_converter = mod.method(:_)
23
+ end
24
+ klass = ::Class.new(self)
18
25
 
19
26
  if args.first.is_a?(String)
20
27
  name = args.shift
@@ -35,6 +42,7 @@ else
35
42
  instance.send(:initialize, **init_kwargs, &block)
36
43
  end.freeze
37
44
  end
45
+
38
46
  class << klass
39
47
  alias_method :[], :new
40
48
  undef_method :define
@@ -49,6 +57,10 @@ else
49
57
  end
50
58
  end
51
59
 
60
+ if arity_converter
61
+ klass.class_eval(&arity_converter)
62
+ end
63
+
52
64
  klass
53
65
  end
54
66
 
@@ -99,12 +111,14 @@ else
99
111
  end
100
112
 
101
113
  def inspect
102
- name = ["data", self.class.name].compact.join(" ")
103
114
  attribute_markers = @attributes.map do |key, value|
104
115
  insect_key = key.to_s.start_with?("@") ? ":#{key}" : key
105
116
  "#{insect_key}=#{value}"
106
- end
107
- %(#<#{name} #{attribute_markers.join(", ")}>)
117
+ end.join(", ")
118
+
119
+ display = ["data", self.class.name, attribute_markers].compact.join(" ")
120
+
121
+ "#<#{display}>"
108
122
  end
109
123
  alias_method :to_s, :inspect
110
124
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Polyfill
4
4
  module Data
5
- VERSION = "1.0.4"
5
+ VERSION = "1.0.5"
6
6
  end
7
7
  end
data/test/test_data.rb CHANGED
@@ -269,4 +269,25 @@ class TestData < Minitest::Test
269
269
 
270
270
  assert_equal(Data::Measure, klass)
271
271
  end
272
+
273
+ def test_member_precedence
274
+ name_mod = Module.new do
275
+ def name
276
+ "default name"
277
+ end
278
+
279
+ def other
280
+ "other"
281
+ end
282
+ end
283
+
284
+ klass = Data.define(:name) do
285
+ include name_mod
286
+ end
287
+
288
+ data = klass.new("test")
289
+
290
+ assert_equal("test", data.name)
291
+ assert_equal("other", data.other)
292
+ end
272
293
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyfill-data
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Gay
@@ -34,7 +34,7 @@ cert_chain:
34
34
  dxkiKqcX+yzo9RJLD9l/E1AWX125r1Fhiif4l6ehdl7Vllc3NQUOm1abdmHtCYjw
35
35
  dG3yPWBWzzN4ovoBRqsuTJbF1wjkCjl5ex5KhfYbeDc=
36
36
  -----END CERTIFICATE-----
37
- date: 2023-01-22 00:00:00.000000000 Z
37
+ date: 2023-01-24 00:00:00.000000000 Z
38
38
  dependencies: []
39
39
  description: Add the ruby 3.2 Data class to older rubies. Do nothing in 3.2
40
40
  email:
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  requirements: []
79
- rubygems_version: 3.1.6
79
+ rubygems_version: 3.2.27
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Add the ruby 3.2 Data class to older rubies
metadata.gz.sig CHANGED
Binary file