Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0"
".": "0.1.1"
}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.1.1 (2025-04-08)

Full Changelog: [v0.1.0...v0.1.1](https://github.com/orbcorp/orb-ruby/compare/v0.1.0...v0.1.1)

### Chores

* **internal:** version bump ([ef344e2](https://github.com/orbcorp/orb-ruby/commit/ef344e295d437e08f33fc7091a89be121ee6c5e9))
* loosen const and integer coercion rules ([#246](https://github.com/orbcorp/orb-ruby/issues/246)) ([715a138](https://github.com/orbcorp/orb-ruby/commit/715a138f44ddf1eaf26c4ffec32178f8591eb8d0))

## 0.1.0 (2025-04-08)

Full Changelog: [v0.1.0-alpha.39...v0.1.0](https://github.com/orbcorp/orb-ruby/compare/v0.1.0-alpha.39...v0.1.0)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GIT
PATH
remote: .
specs:
orb-billing (0.1.0.pre.alpha.39)
orb-billing (0.1.0)
connection_pool

GEM
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
<!-- x-release-please-start-version -->

```ruby
gem "orb-billing", "~> 0.1.0.pre.alpha.39"
gem "orb-billing", "~> 0.1.0"
```

<!-- x-release-please-end -->
Expand Down
24 changes: 16 additions & 8 deletions lib/orb/internal/type/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ def coerce(
if value.is_a?(Integer)
exactness[:yes] += 1
return value
elsif strictness == :strong
elsif strictness == :strong && Integer(value, exception: false) != value
message = "no implicit conversion of #{value.class} into #{target.inspect}"
raise TypeError.new(message)
raise value.is_a?(Numeric) ? ArgumentError.new(message) : TypeError.new(message)
else
Kernel.then do
return Integer(value).tap { exactness[:maybe] += 1 }
Expand Down Expand Up @@ -197,12 +197,20 @@ def coerce(
else
end
in Symbol
if (value.is_a?(Symbol) || value.is_a?(String)) && value.to_sym == target
exactness[:yes] += 1
return target
elsif strictness == :strong
message = "cannot convert non-matching #{value.class} into #{target.inspect}"
raise ArgumentError.new(message)
case value
in Symbol | String
if value.to_sym == target
exactness[:yes] += 1
return target
else
exactness[:maybe] += 1
return value
end
else
if strictness == :strong
message = "cannot convert non-matching #{value.class} into #{target.inspect}"
raise ArgumentError.new(message)
end
end
else
end
Expand Down
2 changes: 1 addition & 1 deletion lib/orb/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Orb
VERSION = "0.1.0"
VERSION = "0.1.1"
end
10 changes: 5 additions & 5 deletions test/orb/internal/type/base_model_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def test_coerce_errors
[Integer, "one"] => TypeError,
[Float, "one"] => TypeError,
[String, Time] => TypeError,
[:a, "one"] => ArgumentError,
[Date, "one"] => ArgumentError,
[Time, "one"] => ArgumentError
}
Expand Down Expand Up @@ -346,7 +345,7 @@ def test_coerce
[M2, {a: "1990-09-19", c: nil}] => [{yes: 2, maybe: 2}, {a: "1990-09-19", c: nil}],

[M3, {c: "c", d: "d"}] => [{yes: 3}, {c: :c, d: :d}],
[M3, {c: "d", d: "c"}] => [{yes: 1, no: 2}, {c: "d", d: "c"}],
[M3, {c: "d", d: "c"}] => [{yes: 1, maybe: 2}, {c: "d", d: "c"}],

[M4, {c: 2}] => [{yes: 5}, {c: 2}],
[M4, {a: "1", c: 2}] => [{yes: 4, maybe: 1}, {a: "1", c: 2}],
Expand Down Expand Up @@ -404,7 +403,8 @@ def test_accessors
cases = {
M2.new({a: "1990-09-19", b: "1"}) => {a: Time.new(1990, 9, 19), b: TypeError},
M2.new(a: "one", b: "one") => {a: ArgumentError, b: TypeError},
M2.new(a: nil, b: 2.0) => {a: TypeError, b: TypeError},
M2.new(a: nil, b: 2.0) => {a: TypeError},
M2.new(a: nil, b: 2.2) => {a: TypeError, b: ArgumentError},

M3.new => {d: :d},
M3.new(d: 1) => {d: ArgumentError},
Expand Down Expand Up @@ -520,8 +520,8 @@ def test_coerce
[U0, :""] => [{no: 1}, 0, :""],

[U1, "a"] => [{yes: 1}, 1, :a],
[U1, "2"] => [{maybe: 1}, 2, 2],
[U1, :b] => [{no: 1}, 2, :b],
[U1, "2"] => [{maybe: 1}, 2, "2"],
[U1, :b] => [{maybe: 1}, 2, :b],

[U2, {type: :a}] => [{yes: 3}, 0, {t: :a}],
[U2, {type: "b"}] => [{yes: 3}, 0, {type: :b}],
Expand Down
Loading