Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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 dry-struct.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = ">= 3.1.0"

spec.add_runtime_dependency "ice_nine" if RUBY_ENGINE != "ruby"
spec.add_runtime_dependency "zeitwerk", "~> 2.6"
spec.add_runtime_dependency "dry-core", "~> 1.1"
spec.add_runtime_dependency "dry-types", "~> 1.8", ">= 1.8.2"
spec.add_runtime_dependency "ice_nine", "~> 0.11"
spec.add_development_dependency "bundler"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
Expand Down
18 changes: 12 additions & 6 deletions lib/dry/struct/value.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# frozen_string_literal: true

require "ice_nine"
require "ice_nine" if RUBY_ENGINE != "ruby"

module Dry
class Struct
extend Core::Deprecations[:"dry-struct"]

# {Value} objects behave like {Struct}s but *deeply frozen*
# using [`ice_nine`](https://github.com/dkubb/ice_nine)
# using `Ractor.make_shareable`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment probably needs an update to mention the different strategies per platform.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! 3396141

#
# @example
# class Location < Dry::Struct::Value
Expand All @@ -21,15 +21,21 @@ class Struct
# loc1.frozen? #=> true
# loc2.frozen? #=> true
# loc1 == loc2 #=> true
#
# @see https://github.com/dkubb/ice_nine
class Value < self
abstract

# @param (see ClassInterface#new)
# @return [Value]
# @see https://github.com/dkubb/ice_nine
def self.new(*) = ::IceNine.deep_freeze(super)
def self.new(*)
obj = super
if defined?(::Ractor)
::Ractor.make_shareable(obj)
elsif defined?(::IceNine)
::IceNine.deep_freeze(obj)
else
obj.freeze
end
end
end

deprecate_constant :Value
Expand Down
1 change: 0 additions & 1 deletion repo-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ gemspec:
- [zeitwerk, "~> 2.6"]
- [dry-core, "~> 1.1"]
- [dry-types, "~> 1.8", ">= 1.8.2"]
- [ice_nine, "~> 0.11"]
Loading