Skip to content

Commit

Permalink
refactor(actionpack): move not changed methods to generated
Browse files Browse the repository at this point in the history
cf. #715 (comment)

> Could you move the methods only what you changed, please? If my understanding is correct, only `ActionController::Helpers::ClassMethods#helper` and `AbstractController::Caching::Fragments::ClassMethods#fragment_cache_key` should be moved and modified.

revert d7a4fb5 and 08b92b9 excluding 7d95c0d and 1367681
  • Loading branch information
sanfrecce-osaka committed Nov 9, 2024
1 parent 6b169ec commit 939ac11
Show file tree
Hide file tree
Showing 2 changed files with 208 additions and 192 deletions.
192 changes: 0 additions & 192 deletions gems/actionpack/6.0/actioncontroller.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -178,41 +178,7 @@ end

module AbstractController
module Helpers
extend ActiveSupport::Concern

class MissingHelperError < LoadError
def initialize: (untyped error, untyped path) -> untyped
end

module ClassMethods
# When a class is inherited, wrap its helper module in a new module.
# This ensures that the parent class's module can be changed
# independently of the child class's.
def inherited: (untyped klass) -> untyped

# Declare a controller method as a helper. For example, the following
# makes the +current_user+ and +logged_in?+ controller methods available
# to the view:
# class ApplicationController < ActionController::Base
# helper_method :current_user, :logged_in?
#
# def current_user
# @current_user ||= User.find_by(id: session[:user])
# end
#
# def logged_in?
# current_user != nil
# end
# end
#
# In a view:
# <% if logged_in? -%>Welcome, <%= current_user.name %><% end -%>
#
# ==== Parameters
# * <tt>method[, method]</tt> - A name or names of a method on the controller
# to be made available on the view.
def helper_method: (*untyped meths) -> untyped

# The +helper+ class method can take a series of helper module names, a block, or both.
#
# ==== Options
Expand Down Expand Up @@ -248,63 +214,13 @@ module AbstractController
# helper(:three, BlindHelper) { def mice() 'mice' end }
#
def helper: (*untyped args) ?{ () -> untyped } -> untyped

# Clears up all existing helpers in this class, only keeping the helper
# with the same name as this class.
def clear_helpers: () -> untyped

# Returns a list of modules, normalized from the acceptable kinds of
# helpers with the following behavior:
#
# String or Symbol:: :FooBar or "FooBar" becomes "foo_bar_helper",
# and "foo_bar_helper.rb" is loaded using require_dependency.
#
# Module:: No further processing
#
# After loading the appropriate files, the corresponding modules
# are returned.
#
# ==== Parameters
# * <tt>args</tt> - An array of helpers
#
# ==== Returns
# * <tt>Array</tt> - A normalized list of modules for the list of
# helpers provided.
def modules_for_helpers: (untyped args) -> untyped

private

# Makes all the (instance) methods in the helper module available to templates
# rendered through this controller.
#
# ==== Parameters
# * <tt>module</tt> - The module to include into the current helper module
# for the class
def add_template_helper: (untyped mod) -> untyped

def default_helper_module!: () -> untyped
end
end
end

module AbstractController
module Caching
# Fragment caching is used for caching various blocks within
# views without caching the entire action as a whole. This is
# useful when certain elements of an action change frequently or
# depend on complicated state while other parts rarely change or
# can be shared amongst multiple parties. The caching is done using
# the +cache+ helper available in the Action View. See
# ActionView::Helpers::CacheHelper for more information.
#
# While it's strongly recommended that you use key-based cache
# expiration (see links in CacheHelper for more information),
# it is also possible to manually expire caches. For example:
#
# expire_fragment('name_of_cache')
module Fragments
extend ActiveSupport::Concern

module ClassMethods
# Allows you to specify controller-wide key prefixes for
# cache fragments. Pass either a constant +value+, or a block
Expand All @@ -329,121 +245,13 @@ module AbstractController
# end
def fragment_cache_key: (?untyped? value) ?{ () -> untyped } -> untyped
end

# Given a key (as described in +expire_fragment+), returns
# a key array suitable for use in reading, writing, or expiring a
# cached fragment. All keys begin with <tt>:views</tt>,
# followed by <tt>ENV["RAILS_CACHE_ID"]</tt> or <tt>ENV["RAILS_APP_VERSION"]</tt> if set,
# followed by any controller-wide key prefix values, ending
# with the specified +key+ value.
def combined_fragment_cache_key: (untyped key) -> untyped

# Writes +content+ to the location signified by
# +key+ (see +expire_fragment+ for acceptable formats).
def write_fragment: (untyped key, untyped content, ?untyped? options) -> untyped

# Reads a cached fragment from the location signified by +key+
# (see +expire_fragment+ for acceptable formats).
def read_fragment: (untyped key, ?untyped? options) -> (nil | untyped)

# Check if a cached fragment from the location signified by
# +key+ exists (see +expire_fragment+ for acceptable formats).
def fragment_exist?: (untyped key, ?untyped? options) -> (nil | untyped)

# Removes fragments from the cache.
#
# +key+ can take one of three forms:
#
# * String - This would normally take the form of a path, like
# <tt>pages/45/notes</tt>.
# * Hash - Treated as an implicit call to +url_for+, like
# <tt>{ controller: 'pages', action: 'notes', id: 45}</tt>
# * Regexp - Will remove any fragment that matches, so
# <tt>%r{pages/\d*/notes}</tt> might remove all notes. Make sure you
# don't use anchors in the regex (<tt>^</tt> or <tt>$</tt>) because
# the actual filename matched looks like
# <tt>./cache/filename/path.cache</tt>. Note: Regexp expiration is
# only supported on caches that can iterate over all keys (unlike
# memcached).
#
# +options+ is passed through to the cache store's +delete+
# method (or <tt>delete_matched</tt>, for Regexp keys).
def expire_fragment: (untyped key, ?untyped? options) -> (nil | untyped)

def instrument_fragment_cache: (untyped name, untyped key) { () -> untyped } -> untyped
end
end
end

module AbstractController
module Caching
extend ActiveSupport::Concern

extend ActiveSupport::Autoload

module ConfigMethods
def cache_store: () -> untyped

def cache_store=: (untyped store) -> untyped

private

def cache_configured?: () -> untyped
end

include ConfigMethods

include AbstractController::Caching::Fragments
extend AbstractController::Caching::Fragments::ClassMethods

extend ConfigMethods

module ClassMethods
def view_cache_dependency: () { () -> untyped } -> untyped
end

def view_cache_dependencies: () -> untyped

private

def cache: (untyped key, ?::Hash[untyped, untyped] options) { () -> untyped } -> untyped
end
end

module ActionController
# \Caching is a cheap way of speeding up slow applications by keeping the result of
# calculations, renderings, and database calls around for subsequent requests.
#
# You can read more about each approach by clicking the modules below.
#
# Note: To turn off all caching provided by Action Controller, set
# config.action_controller.perform_caching = false
#
# == \Caching stores
#
# All the caching stores from ActiveSupport::Cache are available to be used as backends
# for Action Controller caching.
#
# Configuration examples (FileStore is the default):
#
# config.action_controller.cache_store = :memory_store
# config.action_controller.cache_store = :file_store, '/path/to/cache/directory'
# config.action_controller.cache_store = :mem_cache_store, 'localhost'
# config.action_controller.cache_store = :mem_cache_store, Memcached::Rails.new('localhost:11211')
# config.action_controller.cache_store = MyOwnStore.new('parameter')
module Caching
extend ActiveSupport::Autoload

extend ActiveSupport::Concern

include AbstractController::Caching
extend AbstractController::Caching::ClassMethods
extend AbstractController::Caching::Fragments::ClassMethods

private

def instrument_payload: (untyped key) -> { controller: untyped, action: untyped, key: untyped }

def instrument_name: () -> "action_controller"
end
end
Loading

0 comments on commit 939ac11

Please sign in to comment.