Sha256: 51f18bdafedea89ff062322e14a10f9d341ab955c22a69f4d4dae2b13e9bb6b0
Contents?: true
Size: 797 Bytes
Versions: 2
Compression:
Stored size: 797 Bytes
Contents
require 'ice_nine' module Dry class Struct # {Value} objects behave like {Struct}s but *deeply frozen* # using [`ice_nine`](https://github.com/dkubb/ice_nine) # # @example # class Location < Dry::Struct::Value # attribute :lat, Types::Float # attribute :lng, Types::Float # end # # loc1 = Location.new(lat: 1.23, lng: 4.56) # loc2 = Location.new(lat: 1.23, lng: 4.56) # # loc1.frozen? #=> true # loc2.frozen? #=> true # loc1 == loc2 #=> true # # @see https://github.com/dkubb/ice_nine class Value < self # @param (see ClassInterface#new) # @return [Value] # @see https://github.com/dkubb/ice_nine def self.new(*) IceNine.deep_freeze(super) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dry-struct-1.1.1 | lib/dry/struct/value.rb |
dry-struct-1.1.0 | lib/dry/struct/value.rb |