memoizable 0.5.0 → 0.5.1

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: 9b9efbfc2d856bca857e97e84678b1e49977e2b1f4d0a0d93a239cacea9b95ef
4
- data.tar.gz: 93a3c69fb399accdc6a8f684c315284c46450af48c5df0d4eb05117af1e2ea2e
3
+ metadata.gz: 05b0a35f4ebc935666647d856669bf51e434eb04813927c0c78203a37598602a
4
+ data.tar.gz: fb929afe7b3111fbff2e182ac6b3b9a4ea5d7cbc86249eae3426880345dce45b
5
5
  SHA512:
6
- metadata.gz: de5d824ac3bd2b23970c50463cc27ba3a83b2f102d0293475edde45b1cebcccb87e5fac3411b6d509ce8866307d8f6eb213b8dc2c81eb17874df162c93329797
7
- data.tar.gz: 5ae626655e57e079b0a6ea42d9a194e300fc681ec0b3403d1e7c08dea362075a1678041133df583ce296011baaa28da72c1f6e67bab47b067aa633146580658b
6
+ metadata.gz: 92b9a5166e335aa55860aa18d7e41d5119ab12f588b8d90112c7fccc5b0904181e953ca0acd8715c6d8c16e27b32c09764c288699dfbba383e35ad6dac873865
7
+ data.tar.gz: e24a089cd4d0b74a68f2961ff695133ff532597d5c6bf3530b4bb5bbe1c778fa302ded54e396625d7e13dfada9b56e978b13a04b37b42c4f9502696884b521bf
data/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.5.1] - 2026-03-03
11
+
12
+ ### Fixed
13
+
14
+ - Include RBS signature file in gem package
15
+
10
16
  ## [0.5.0] - 2026-02-09
11
17
 
12
18
  ### Added
@@ -90,7 +96,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
90
96
  - `ModuleMethods#unmemoized_instance_method` to access original method
91
97
  - Thread-safe cache using `ThreadSafe::Cache`
92
98
 
93
- [Unreleased]: https://github.com/dkubb/memoizable/compare/v0.5.0...HEAD
99
+ [Unreleased]: https://github.com/dkubb/memoizable/compare/v0.5.1...HEAD
100
+ [0.5.1]: https://github.com/dkubb/memoizable/compare/v0.5.0...v0.5.1
94
101
  [0.5.0]: https://github.com/dkubb/memoizable/compare/v0.4.2...v0.5.0
95
102
  [0.4.2]: https://github.com/dkubb/memoizable/compare/v0.4.1...v0.4.2
96
103
  [0.4.1]: https://github.com/dkubb/memoizable/compare/v0.4.0...v0.4.1
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Memoizable
4
4
  # Gem version
5
- VERSION = "0.5.0"
5
+ VERSION = "0.5.1"
6
6
  end
@@ -0,0 +1,138 @@
1
+ # Type definitions for Memoizable
2
+
3
+ module Memoizable
4
+ VERSION: String
5
+
6
+ # Cache key type: [defining_class, method_name]
7
+ type cache_key = [Module, Symbol]
8
+
9
+ include InstanceMethods
10
+
11
+ # Default freezer that freezes objects
12
+ Freezer: untyped
13
+
14
+ # Hook called when module is included
15
+ def self.included: (Module descendant) -> void
16
+
17
+ # Methods mixed in to memoizable instances
18
+ module InstanceMethods
19
+ @_memoized_method_cache: Memory?
20
+
21
+ # Freeze the object
22
+ def freeze: () -> self
23
+
24
+ # Sets memoized values for methods
25
+ def memoize: (Hash[Symbol, untyped] data) -> self
26
+
27
+ private
28
+
29
+ # The memoized method results
30
+ def memoized_method_cache: () -> Memory
31
+ end
32
+
33
+ # Methods mixed in to memoizable singleton classes
34
+ module ModuleMethods : Module
35
+ include Memoizable
36
+
37
+ @memoized_methods: Hash[Symbol, MethodBuilder]?
38
+
39
+ # Return default deep freezer
40
+ def freezer: () -> untyped
41
+
42
+ # Memoize a list of methods
43
+ def memoize: (*Symbol methods) -> self
44
+
45
+ # Return unmemoized instance method
46
+ def unmemoized_instance_method: (Symbol name) -> UnboundMethod
47
+
48
+ private
49
+
50
+ # Memoize the named method
51
+ def memoize_method: (Symbol method_name) -> void
52
+
53
+ # Return method builder registry
54
+ def memoized_methods: () -> Hash[Symbol, MethodBuilder]
55
+ end
56
+
57
+ # Storage for memoized methods
58
+ class Memory
59
+ @memory: Hash[cache_key, untyped]
60
+ @monitor: ::Monitor
61
+
62
+ # Initialize the memory storage
63
+ def initialize: (Hash[cache_key, untyped] memory) -> void
64
+
65
+ # Get the value from memory
66
+ def []: (cache_key name) -> untyped
67
+
68
+ # Store the value in memory
69
+ def store: (cache_key name, untyped value) -> untyped
70
+
71
+ # Fetch the value from memory, or store it if it does not exist
72
+ def fetch: (cache_key name, ?untyped default) ?{ () -> untyped } -> untyped
73
+
74
+ # Remove a specific value from memory
75
+ def delete: (cache_key name) -> untyped
76
+
77
+ # Remove all values from memory
78
+ def clear: () -> self
79
+
80
+ # A hook that allows Marshal to dump the object
81
+ def marshal_dump: () -> Hash[cache_key, untyped]
82
+
83
+ # A hook that allows Marshal to load the object
84
+ def marshal_load: (Hash[cache_key, untyped] hash) -> void
85
+
86
+ private
87
+
88
+ # Resolve the value for a fetch operation
89
+ def resolve_fetch_value: (cache_key name, bool no_default, untyped default) ?{ () -> untyped } -> untyped
90
+ end
91
+
92
+ # Build the memoized method
93
+ class MethodBuilder
94
+ @descendant: Module
95
+ @method_name: Symbol
96
+ @freezer: untyped
97
+ @original_visibility: Symbol
98
+ @original_method: UnboundMethod
99
+
100
+ # Raised when the method arity is invalid
101
+ class InvalidArityError < ArgumentError
102
+ # Initialize an invalid arity exception
103
+ def initialize: (Module descendant, Symbol method, Integer arity) -> void
104
+ end
105
+
106
+ # Raised when a block is passed to a memoized method
107
+ class BlockNotAllowedError < ArgumentError
108
+ # Initialize a block not allowed exception
109
+ def initialize: (Module descendant, Symbol method) -> void
110
+ end
111
+
112
+ # The original method before memoization
113
+ attr_reader original_method: UnboundMethod
114
+
115
+ # Initialize an object to build a memoized method
116
+ def initialize: (Module descendant, Symbol method_name, untyped freezer) -> void
117
+
118
+ # Build a new memoized method
119
+ def call: () -> self
120
+
121
+ private
122
+
123
+ # Assert the method arity is zero
124
+ def assert_arity: (Integer arity) -> void
125
+
126
+ # Remove the original method
127
+ def remove_original_method: () -> void
128
+
129
+ # Create a new memoized method
130
+ def create_memoized_method: () -> untyped
131
+
132
+ # Set the memoized method visibility to match the original method
133
+ def set_method_visibility: () -> untyped
134
+
135
+ # Get the visibility of the original method
136
+ def visibility: () -> Symbol
137
+ end
138
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memoizable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Kubb
@@ -28,6 +28,7 @@ files:
28
28
  - lib/memoizable/method_builder.rb
29
29
  - lib/memoizable/module_methods.rb
30
30
  - lib/memoizable/version.rb
31
+ - sig/memoizable.rbs
31
32
  homepage: https://github.com/dkubb/memoizable
32
33
  licenses:
33
34
  - MIT