optify-from_hash 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: defb046567cf5eb3f38edf14687a1b6d62f6525b8f51cb09b2192238f974cac6
4
- data.tar.gz: 8c812657f197ea275174418c9d337a5f6f8c129bdd28e58486c15e0d7a9ac519
3
+ metadata.gz: ab3e37acc0afa16b17fbfb4bcbbf95e31b38d75c321d3d3d3a9a9f8a9fb7afb5
4
+ data.tar.gz: b087d7433c8329a6e62262d129f80cd538dae2459337e619ad2ab760df21bbc5
5
5
  SHA512:
6
- metadata.gz: e20d38e4ef67f073fa5c3db61bdd77eaf6b54a059ca57fedfb518a8c0f0a66b5598740dcefc12f8fe13fdffb21e834d6d079bcc189599e88b983d34a4bcddefe
7
- data.tar.gz: 4a6f118ce068585191c3d5193ea9c0ef135f65a653b5193464ddb5a0dce3e3a3e799b85c3f63037b6b9b47cb83b9dcdbcd6b9b9b2f34eb6a04dcc84143275a4c
6
+ metadata.gz: 968c5aa5b223c043a8558f5e2ac2b4cf8efb7925ed408bf6dffc458734a51a6da0d4b85e781688354b8432c0b6307067c4102521f7792d801859a1a80bdf391c
7
+ data.tar.gz: 57b11b0707b45887e544ad8d32286e0780a37d89f1fc87ea293139ed13a26140e2cde81cf1afe534827e4c9be69e6a3c5812b236b2ed5fd6438e73e1985ed206
@@ -1,6 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
+ require 'json'
4
5
  require 'sorbet-runtime'
5
6
  require 'tapioca'
6
7
 
@@ -114,6 +115,12 @@ module Optify
114
115
  end
115
116
  end
116
117
 
118
+ # Convert this object to a JSON string.
119
+ #: (*untyped) -> String
120
+ def to_json(*args)
121
+ to_h.to_json(args)
122
+ end
123
+
117
124
  # Convert this object to a Hash recursively.
118
125
  # This is mostly the reverse operation of `from_hash`,
119
126
  # as keys will be symbols
@@ -5,8 +5,6 @@
5
5
  module Optify
6
6
  # A base class for classes that can be created from a hash.
7
7
  class FromHashable
8
- extend T::Sig
9
- extend T::Helpers
10
8
  abstract!
11
9
 
12
10
  # Create a new instance of the class from a hash.
@@ -17,6 +15,10 @@ module Optify
17
15
  sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
18
16
  def self.from_hash(hash); end
19
17
 
18
+ # Convert this object to a JSON string.
19
+ sig { params(args: T.untyped).returns(String) }
20
+ def to_json(*args); end
21
+
20
22
  # Convert this object to a Hash recursively.
21
23
  # This is mostly the reverse operation of `from_hash`,
22
24
  # as keys will be symbols
@@ -4,8 +4,6 @@ end
4
4
 
5
5
  # A base class for classes that can be created from a hash.
6
6
  class Optify::FromHashable
7
- extend T::Helpers
8
-
9
7
  # Create a new instance of the class from a hash.
10
8
  #
11
9
  # This is a class method that so that it can set members with private setters.
@@ -13,6 +11,9 @@ class Optify::FromHashable
13
11
  # @return The new instance.
14
12
  def self.from_hash: (::Hash[untyped, untyped] hash) -> instance
15
13
 
14
+ # Convert this object to a JSON string.
15
+ def to_json: (*untyped args) -> String
16
+
16
17
  # Convert this object to a Hash recursively.
17
18
  # This is mostly the reverse operation of `from_hash`,
18
19
  # as keys will be symbols
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optify-from_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin D. Harris
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  - !ruby/object:Gem::Version
135
135
  version: '0'
136
136
  requirements: []
137
- rubygems_version: 3.7.2
137
+ rubygems_version: 3.6.7
138
138
  specification_version: 4
139
139
  summary: Utilities for converting hashes to immutable objects.
140
140
  test_files: []