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 +4 -4
- data/lib/optify_from_hash/from_hashable.rb +7 -0
- data/rbi/optify_from_hash.rbi +4 -2
- data/sig/optify_from_hash.rbs +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ab3e37acc0afa16b17fbfb4bcbbf95e31b38d75c321d3d3d3a9a9f8a9fb7afb5
|
|
4
|
+
data.tar.gz: b087d7433c8329a6e62262d129f80cd538dae2459337e619ad2ab760df21bbc5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
data/rbi/optify_from_hash.rbi
CHANGED
|
@@ -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
|
data/sig/optify_from_hash.rbs
CHANGED
|
@@ -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.
|
|
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
|
|
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: []
|