Skip to content

Add RBS for cache_method 0.2 - #1107

Merged
github-actions[bot] merged 2 commits into
ruby:mainfrom
apiology:add-cache-method-signatures
Oct 19, 2026
Merged

github-actions[bot] merged 2 commits into
ruby:mainfrom
apiology:add-cache-method-signatures

Conversation

@apiology

Copy link
Copy Markdown
Contributor

This PR was written by Claude Code on behalf of @apiology.

Problem

Steep rejects cache_method calls in class bodies:

require 'cache_method'
class Tasks
  def task(name) = name
  # Type `singleton(::Tasks)` does not have method `cache_method`
  cache_method :task, 900
end

Every class using the gem's documented DSL fails to type-check.

Solution

Adds RBS for cache_method 0.2, including CacheMethod::ClassMethods into Module and CacheMethod::InstanceMethods into Object just as the gem does at require time, so cache_method, cache_method_clear_on, cache_method_clear and cache_method_cached? resolve wherever Ruby makes them available.

InstanceMethods declares a BasicObject self type; the implicit Object self type would make Object its own ancestor.

apiology and others added 2 commits October 19, 2026 13:10
cache_method includes CacheMethod::ClassMethods into Module and
CacheMethod::InstanceMethods into Object at require time, so class
bodies call cache_method and cache_method_clear_on with no explicit
extend. Model those includes so Steep sees the DSL wherever the gem
makes it available, along with CacheMethod.config and its Config.

InstanceMethods declares a BasicObject self type: the implicit Object
self type would make Object an ancestor of itself once the module is
included into Object.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wo4FerFK9aaxrGrmVE9ncZ
Config#storage= is defined as storage=(storage = nil).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wo4FerFK9aaxrGrmVE9ncZ
@apiology
apiology marked this pull request as ready for review October 19, 2026 20:02
@github-actions

Copy link
Copy Markdown

@apiology Thanks for your contribution!

Please follow the instructions below for each change.
See also: https://github.com/ruby/gem_rbs_collection/blob/main/docs/CONTRIBUTING.md

Available commands

You can use the following commands by commenting on this PR.

  • /merge: Merge this PR if CI passes

cache_method

This RBS files are newly added.

You can merge this PR immediately if the CI passes.
Just comment /merge to merge this PR.

@apiology

Copy link
Copy Markdown
Contributor Author

/merge

@github-actions
github-actions Bot merged commit 93be6ae into ruby:main Oct 19, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant