rbs_rails 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +3 -2
- data/README.md +1 -0
- data/Rakefile +10 -2
- data/Steepfile +1 -0
- data/assets/sig/active_record.rbs +1 -1
- data/assets/sig/generated/actionpack.rbs +697 -543
- data/assets/sig/generated/actionview.rbs +313 -213
- data/assets/sig/generated/activejob.rbs +1920 -0
- data/assets/sig/generated/activemodel.rbs +690 -615
- data/assets/sig/generated/activerecord.rbs +5521 -4942
- data/assets/sig/generated/activesupport.rbs +1613 -1207
- data/assets/sig/generated/railties.rbs +426 -386
- data/assets/sig/patches/README.md +4 -0
- data/assets/sig/patches/for_actionpack.rbs +74 -0
- data/assets/sig/patches/for_actionview.rbs +19 -0
- data/assets/sig/patches/for_activemodel.rbs +11 -0
- data/assets/sig/patches/for_activerecord.rbs +84 -0
- data/assets/sig/patches/for_activesupport.rbs +48 -0
- data/assets/sig/patches/for_railties.rbs +30 -0
- data/assets/sig/pg.rbs +5 -0
- data/assets/sig/que.rbs +4 -0
- data/assets/sig/queue_classic.rbs +4 -0
- data/assets/sig/rack.rbs +1 -0
- data/assets/sig/sidekiq.rbs +4 -0
- data/assets/sig/sneakers.rbs +4 -0
- data/assets/sig/sucker_punch.rbs +4 -0
- data/bin/add-type-params.rb +7 -0
- data/bin/generate_rbs_from_rails_source_code.rb +195 -0
- data/bin/postprocess.rb +15 -6
- data/bin/rbs +1 -1
- data/lib/rbs_rails/active_record.rb +40 -10
- data/lib/rbs_rails/version.rb +1 -1
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16709127e339f2c71c00ad11ac8ed13fa0dae3090c2ee30105486acd2cde536e
|
4
|
+
data.tar.gz: 70464319628ea31b6ba77c958be4e335fcfefa6f55b3908ef168578a5bc4a03e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a26bb616fd9ff5a174c089afdc2f5283c182abe3868dd6fab1b25ca16c7f447c21520915d131b84e00a25e800dca8ca3ff5b5d2c093ac65fab924dd5424221b
|
7
|
+
data.tar.gz: 52d257af8544a3639a3ffd98f3f0917fc5dd503e4682951cce3391ceed94bedf5d9eca1b0cd86b57e67fdc7d90093cf0a5acbc089c744e8bba5a49f38bd19364
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
task :default => [:rbs_validate, :steep, :test]
|
3
5
|
|
4
6
|
desc 'run Steep'
|
5
7
|
task :steep do
|
@@ -7,5 +9,11 @@ task :steep do
|
|
7
9
|
end
|
8
10
|
|
9
11
|
task :rbs_validate do
|
10
|
-
sh 'bin/rbs validate'
|
12
|
+
sh 'bin/rbs validate --silent'
|
13
|
+
end
|
14
|
+
|
15
|
+
Rake::TestTask.new do |test|
|
16
|
+
test.libs << 'test'
|
17
|
+
test.test_files = Dir['test/**/*_test.rb']
|
18
|
+
test.verbose = true
|
11
19
|
end
|
data/Steepfile
CHANGED
@@ -37,7 +37,7 @@ class ActiveRecord::Base
|
|
37
37
|
|
38
38
|
def will_save_change_to_attribute?: (String | Symbol attr_name, ?from: untyped, ?to: untyped) -> bool
|
39
39
|
|
40
|
-
def save!: () -> self
|
40
|
+
def save!: (?validate: bool, ?touch: bool) -> self
|
41
41
|
def save: () -> bool
|
42
42
|
def update!: (*untyped) -> self
|
43
43
|
def update: (*untyped) -> bool
|
@@ -23,6 +23,8 @@ module AbstractController
|
|
23
23
|
|
24
24
|
attr_reader abstract: untyped
|
25
25
|
|
26
|
+
alias self.abstract? self.abstract
|
27
|
+
|
26
28
|
# Define a controller as abstract. See internal_methods for more
|
27
29
|
# details.
|
28
30
|
def self.abstract!: () -> untyped
|
@@ -121,6 +123,13 @@ module AbstractController
|
|
121
123
|
# which is *not* necessarily the same as the action name.
|
122
124
|
def process_action: (untyped method_name, *untyped args) -> untyped
|
123
125
|
|
126
|
+
# Actually call the method associated with the action. Override
|
127
|
+
# this method if you wish to change how action methods are called,
|
128
|
+
# not to add additional behavior around it. For example, you would
|
129
|
+
# override #send_action if you want to inject arguments into the
|
130
|
+
# method.
|
131
|
+
alias send_action send
|
132
|
+
|
124
133
|
# If the action name was not found, but a method called "action_missing"
|
125
134
|
# was found, #method_for_action will return "_handle_action_missing".
|
126
135
|
# This method calls #action_missing with the current action name.
|
@@ -507,12 +516,6 @@ module AbstractController
|
|
507
516
|
end
|
508
517
|
end
|
509
518
|
|
510
|
-
module AbstractController
|
511
|
-
extend ActiveSupport::Autoload
|
512
|
-
|
513
|
-
def self.eager_load!: () -> untyped
|
514
|
-
end
|
515
|
-
|
516
519
|
module AbstractController
|
517
520
|
class DoubleRenderError < Error
|
518
521
|
DEFAULT_MESSAGE: ::String
|
@@ -525,6 +528,8 @@ module AbstractController
|
|
525
528
|
|
526
529
|
include ActionView::ViewPaths
|
527
530
|
|
531
|
+
extend ::ActionView::ViewPaths::ClassMethods
|
532
|
+
|
528
533
|
# Normalizes arguments, options and then delegates render_to_body and
|
529
534
|
# sticks the result in <tt>self.response_body</tt>.
|
530
535
|
def render: (*untyped args) { () -> untyped } -> untyped
|
@@ -585,8 +590,12 @@ module AbstractController
|
|
585
590
|
# simple framework for scoping them consistently.
|
586
591
|
def translate: (untyped key, **untyped options) -> untyped
|
587
592
|
|
593
|
+
alias t translate
|
594
|
+
|
588
595
|
# Delegates to <tt>I18n.localize</tt>. Also aliased as <tt>l</tt>.
|
589
596
|
def localize: (untyped object, **untyped options) -> untyped
|
597
|
+
|
598
|
+
alias l localize
|
590
599
|
end
|
591
600
|
end
|
592
601
|
|
@@ -612,6 +621,12 @@ module AbstractController
|
|
612
621
|
end
|
613
622
|
end
|
614
623
|
|
624
|
+
module AbstractController
|
625
|
+
extend ActiveSupport::Autoload
|
626
|
+
|
627
|
+
def self.eager_load!: () -> untyped
|
628
|
+
end
|
629
|
+
|
615
630
|
module ActionController
|
616
631
|
module ApiRendering
|
617
632
|
extend ActiveSupport::Concern
|
@@ -2416,6 +2431,8 @@ module ActionController
|
|
2416
2431
|
|
2417
2432
|
def `any`: (*untyped args) { () -> untyped } -> untyped
|
2418
2433
|
|
2434
|
+
alias all any
|
2435
|
+
|
2419
2436
|
def custom: (untyped mime_type) { () -> untyped } -> untyped
|
2420
2437
|
|
2421
2438
|
def response: () -> untyped
|
@@ -2428,6 +2445,8 @@ module ActionController
|
|
2428
2445
|
|
2429
2446
|
def `any`: (*untyped args) { () -> untyped } -> untyped
|
2430
2447
|
|
2448
|
+
alias all any
|
2449
|
+
|
2431
2450
|
def method_missing: (untyped name, *untyped args) { () -> untyped } -> untyped
|
2432
2451
|
|
2433
2452
|
def variant: () -> untyped
|
@@ -2547,7 +2566,6 @@ module ActionController
|
|
2547
2566
|
|
2548
2567
|
EXCLUDE_PARAMETERS: ::Array[untyped]
|
2549
2568
|
|
2550
|
-
# Note: It inherits unnamed class, but omitted^
|
2551
2569
|
class Options
|
2552
2570
|
# :nodoc:
|
2553
2571
|
include Mutex_m
|
@@ -2632,148 +2650,6 @@ module ActionController
|
|
2632
2650
|
end
|
2633
2651
|
end
|
2634
2652
|
|
2635
|
-
module ActionController
|
2636
|
-
class MiddlewareStack < ActionDispatch::MiddlewareStack
|
2637
|
-
class Middleware < ActionDispatch::MiddlewareStack::Middleware
|
2638
|
-
# Extend ActionDispatch middleware stack to make it aware of options
|
2639
|
-
# allowing the following syntax in controllers:
|
2640
|
-
#
|
2641
|
-
# class PostsController < ApplicationController
|
2642
|
-
# use AuthenticationMiddleware, except: [:index, :show]
|
2643
|
-
# end
|
2644
|
-
#
|
2645
|
-
# nodoc:
|
2646
|
-
# nodoc:
|
2647
|
-
def initialize: (untyped klass, untyped args, untyped actions, untyped strategy, untyped block) -> untyped
|
2648
|
-
|
2649
|
-
def valid?: (untyped action) -> untyped
|
2650
|
-
end
|
2651
|
-
|
2652
|
-
def build: (untyped action, ?untyped? app) { () -> untyped } -> untyped
|
2653
|
-
|
2654
|
-
INCLUDE: untyped
|
2655
|
-
|
2656
|
-
EXCLUDE: untyped
|
2657
|
-
|
2658
|
-
NULL: untyped
|
2659
|
-
|
2660
|
-
def build_middleware: (untyped klass, untyped args, untyped block) -> Middleware
|
2661
|
-
end
|
2662
|
-
|
2663
|
-
# <tt>ActionController::Metal</tt> is the simplest possible controller, providing a
|
2664
|
-
# valid Rack interface without the additional niceties provided by
|
2665
|
-
# <tt>ActionController::Base</tt>.
|
2666
|
-
#
|
2667
|
-
# A sample metal controller might look like this:
|
2668
|
-
#
|
2669
|
-
# class HelloController < ActionController::Metal
|
2670
|
-
# def index
|
2671
|
-
# self.response_body = "Hello World!"
|
2672
|
-
# end
|
2673
|
-
# end
|
2674
|
-
#
|
2675
|
-
# And then to route requests to your metal controller, you would add
|
2676
|
-
# something like this to <tt>config/routes.rb</tt>:
|
2677
|
-
#
|
2678
|
-
# get 'hello', to: HelloController.action(:index)
|
2679
|
-
#
|
2680
|
-
# The +action+ method returns a valid Rack application for the \Rails
|
2681
|
-
# router to dispatch to.
|
2682
|
-
#
|
2683
|
-
# == Rendering Helpers
|
2684
|
-
#
|
2685
|
-
# <tt>ActionController::Metal</tt> by default provides no utilities for rendering
|
2686
|
-
# views, partials, or other responses aside from explicitly calling of
|
2687
|
-
# <tt>response_body=</tt>, <tt>content_type=</tt>, and <tt>status=</tt>. To
|
2688
|
-
# add the render helpers you're used to having in a normal controller, you
|
2689
|
-
# can do the following:
|
2690
|
-
#
|
2691
|
-
# class HelloController < ActionController::Metal
|
2692
|
-
# include AbstractController::Rendering
|
2693
|
-
# include ActionView::Layouts
|
2694
|
-
# append_view_path "#{Rails.root}/app/views"
|
2695
|
-
#
|
2696
|
-
# def index
|
2697
|
-
# render "hello/index"
|
2698
|
-
# end
|
2699
|
-
# end
|
2700
|
-
#
|
2701
|
-
# == Redirection Helpers
|
2702
|
-
#
|
2703
|
-
# To add redirection helpers to your metal controller, do the following:
|
2704
|
-
#
|
2705
|
-
# class HelloController < ActionController::Metal
|
2706
|
-
# include ActionController::Redirecting
|
2707
|
-
# include Rails.application.routes.url_helpers
|
2708
|
-
#
|
2709
|
-
# def index
|
2710
|
-
# redirect_to root_url
|
2711
|
-
# end
|
2712
|
-
# end
|
2713
|
-
#
|
2714
|
-
# == Other Helpers
|
2715
|
-
#
|
2716
|
-
# You can refer to the modules included in <tt>ActionController::Base</tt> to see
|
2717
|
-
# other features you can bring into your metal controller.
|
2718
|
-
#
|
2719
|
-
class Metal < AbstractController::Base
|
2720
|
-
# Returns the last part of the controller's name, underscored, without the ending
|
2721
|
-
# <tt>Controller</tt>. For instance, PostsController returns <tt>posts</tt>.
|
2722
|
-
# Namespaces are left out, so Admin::PostsController returns <tt>posts</tt> as well.
|
2723
|
-
#
|
2724
|
-
# ==== Returns
|
2725
|
-
# * <tt>string</tt>
|
2726
|
-
def self.controller_name: () -> untyped
|
2727
|
-
|
2728
|
-
def self.make_response!: (untyped request) -> untyped
|
2729
|
-
|
2730
|
-
def self.binary_params_for?: (untyped action) -> ::FalseClass
|
2731
|
-
|
2732
|
-
# Delegates to the class' <tt>controller_name</tt>.
|
2733
|
-
def controller_name: () -> untyped
|
2734
|
-
|
2735
|
-
def initialize: () -> untyped
|
2736
|
-
|
2737
|
-
def params: () -> untyped
|
2738
|
-
|
2739
|
-
def params=: (untyped val) -> untyped
|
2740
|
-
|
2741
|
-
# Basic url_for that can be overridden for more robust functionality.
|
2742
|
-
def url_for: (untyped string) -> untyped
|
2743
|
-
|
2744
|
-
def response_body=: (untyped body) -> (nil | untyped)
|
2745
|
-
|
2746
|
-
# Tests if render or redirect has already happened.
|
2747
|
-
def performed?: () -> untyped
|
2748
|
-
|
2749
|
-
def dispatch: (untyped name, untyped request, untyped response) -> untyped
|
2750
|
-
|
2751
|
-
def set_response!: (untyped response) -> untyped
|
2752
|
-
|
2753
|
-
def set_request!: (untyped request) -> untyped
|
2754
|
-
|
2755
|
-
def to_a: () -> untyped
|
2756
|
-
|
2757
|
-
def reset_session: () -> untyped
|
2758
|
-
|
2759
|
-
def self.inherited: (untyped base) -> untyped
|
2760
|
-
|
2761
|
-
# Pushes the given Rack middleware and its arguments to the bottom of the
|
2762
|
-
# middleware stack.
|
2763
|
-
def self.use: (*untyped args) { () -> untyped } -> untyped
|
2764
|
-
|
2765
|
-
# Alias for +middleware_stack+.
|
2766
|
-
def self.middleware: () -> untyped
|
2767
|
-
|
2768
|
-
# Returns a Rack endpoint for the given action name.
|
2769
|
-
def self.action: (untyped name) -> untyped
|
2770
|
-
|
2771
|
-
# Direct dispatch to the controller. Instantiates the controller, then
|
2772
|
-
# executes the action named +name+.
|
2773
|
-
def self.dispatch: (untyped name, untyped req, untyped res) -> untyped
|
2774
|
-
end
|
2775
|
-
end
|
2776
|
-
|
2777
2653
|
module ActionController
|
2778
2654
|
module Redirecting
|
2779
2655
|
extend ActiveSupport::Concern
|
@@ -2970,6 +2846,8 @@ module ActionController
|
|
2970
2846
|
# You must specify a +use_renderer+, else the +controller.renderer+ and
|
2971
2847
|
# +controller._renderers+ will be <tt>nil</tt>, and the action will fail.
|
2972
2848
|
def use_renderers: (*untyped args) -> untyped
|
2849
|
+
|
2850
|
+
alias use_renderer use_renderers
|
2973
2851
|
end
|
2974
2852
|
|
2975
2853
|
# Called by +render+ in <tt>AbstractController::Rendering</tt>
|
@@ -3646,6 +3524,8 @@ module ActionController
|
|
3646
3524
|
# This method is also aliased as +to_param+.
|
3647
3525
|
def to_query: (*untyped args) -> untyped
|
3648
3526
|
|
3527
|
+
alias to_param to_query
|
3528
|
+
|
3649
3529
|
# Returns an unsafe, unfiltered
|
3650
3530
|
# <tt>ActiveSupport::HashWithIndifferentAccess</tt> representation of the
|
3651
3531
|
# parameters.
|
@@ -3658,10 +3538,14 @@ module ActionController
|
|
3658
3538
|
# # => {"name"=>"Senjougahara Hitagi", "oddity" => "Heavy stone crab"}
|
3659
3539
|
def to_unsafe_h: () -> untyped
|
3660
3540
|
|
3541
|
+
alias to_unsafe_hash to_unsafe_h
|
3542
|
+
|
3661
3543
|
# Convert all hashes in values into parameters, then yield each pair in
|
3662
3544
|
# the same way as <tt>Hash#each_pair</tt>.
|
3663
3545
|
def each_pair: () { (untyped) -> untyped } -> untyped
|
3664
3546
|
|
3547
|
+
alias each each_pair
|
3548
|
+
|
3665
3549
|
# Convert all hashes in values into parameters, then yield each value in
|
3666
3550
|
# the same way as <tt>Hash#each_value</tt>.
|
3667
3551
|
def each_value: () { (untyped) -> untyped } -> untyped
|
@@ -3749,6 +3633,9 @@ module ActionController
|
|
3749
3633
|
# for example.
|
3750
3634
|
def require: (untyped key) -> untyped
|
3751
3635
|
|
3636
|
+
# Alias of #require.
|
3637
|
+
alias required require
|
3638
|
+
|
3752
3639
|
# Returns a new <tt>ActionController::Parameters</tt> instance that
|
3753
3640
|
# includes only the given +filters+ and sets the +permitted+ attribute
|
3754
3641
|
# for the object to +true+. This is useful for limiting which attributes
|
@@ -3928,6 +3815,8 @@ module ActionController
|
|
3928
3815
|
# Equivalent to Hash#keep_if, but returns +nil+ if no changes were made.
|
3929
3816
|
def select!: () { () -> untyped } -> untyped
|
3930
3817
|
|
3818
|
+
alias keep_if select!
|
3819
|
+
|
3931
3820
|
# Returns a new instance of <tt>ActionController::Parameters</tt> with items
|
3932
3821
|
# that the block evaluates to true removed.
|
3933
3822
|
def reject: () { () -> untyped } -> untyped
|
@@ -3935,6 +3824,8 @@ module ActionController
|
|
3935
3824
|
# Removes items that the block evaluates to true and returns self.
|
3936
3825
|
def reject!: () { () -> untyped } -> untyped
|
3937
3826
|
|
3827
|
+
alias delete_if reject!
|
3828
|
+
|
3938
3829
|
# Returns values that were assigned to the given +keys+. Note that all the
|
3939
3830
|
# +Hash+ objects will be converted to <tt>ActionController::Parameters</tt>.
|
3940
3831
|
def values_at: (*untyped keys) -> untyped
|
@@ -3951,10 +3842,14 @@ module ActionController
|
|
3951
3842
|
# current hash merged into +other_hash+.
|
3952
3843
|
def reverse_merge: (untyped other_hash) -> untyped
|
3953
3844
|
|
3845
|
+
alias with_defaults reverse_merge
|
3846
|
+
|
3954
3847
|
# Returns current <tt>ActionController::Parameters</tt> instance with
|
3955
3848
|
# current hash merged into +other_hash+.
|
3956
3849
|
def reverse_merge!: (untyped other_hash) -> untyped
|
3957
3850
|
|
3851
|
+
alias with_defaults! reverse_merge!
|
3852
|
+
|
3958
3853
|
def stringify_keys: () -> untyped
|
3959
3854
|
|
3960
3855
|
def inspect: () -> ::String
|
@@ -4152,55 +4047,195 @@ module ActionController
|
|
4152
4047
|
end
|
4153
4048
|
|
4154
4049
|
module ActionController
|
4155
|
-
class
|
4156
|
-
|
4157
|
-
|
4158
|
-
|
4050
|
+
class MiddlewareStack < ActionDispatch::MiddlewareStack
|
4051
|
+
class Middleware < ActionDispatch::MiddlewareStack::Middleware
|
4052
|
+
# Extend ActionDispatch middleware stack to make it aware of options
|
4053
|
+
# allowing the following syntax in controllers:
|
4054
|
+
#
|
4055
|
+
# class PostsController < ApplicationController
|
4056
|
+
# use AuthenticationMiddleware, except: [:index, :show]
|
4057
|
+
# end
|
4058
|
+
#
|
4059
|
+
# nodoc:
|
4060
|
+
# nodoc:
|
4061
|
+
def initialize: (untyped klass, untyped args, untyped actions, untyped strategy, untyped block) -> untyped
|
4159
4062
|
|
4160
|
-
|
4161
|
-
module Railties
|
4162
|
-
module Helpers
|
4163
|
-
def inherited: (untyped klass) -> (nil | untyped)
|
4063
|
+
def valid?: (untyped action) -> untyped
|
4164
4064
|
end
|
4165
|
-
end
|
4166
|
-
end
|
4167
4065
|
|
4168
|
-
|
4169
|
-
extend ActiveSupport::Autoload
|
4170
|
-
end
|
4066
|
+
def build: (untyped action, ?untyped? app) { () -> untyped } -> untyped
|
4171
4067
|
|
4172
|
-
|
4173
|
-
|
4174
|
-
|
4175
|
-
|
4176
|
-
|
4177
|
-
|
4068
|
+
INCLUDE: untyped
|
4069
|
+
|
4070
|
+
EXCLUDE: untyped
|
4071
|
+
|
4072
|
+
NULL: untyped
|
4073
|
+
|
4074
|
+
def build_middleware: (untyped klass, untyped args, untyped block) -> Middleware
|
4075
|
+
end
|
4076
|
+
|
4077
|
+
# <tt>ActionController::Metal</tt> is the simplest possible controller, providing a
|
4078
|
+
# valid Rack interface without the additional niceties provided by
|
4079
|
+
# <tt>ActionController::Base</tt>.
|
4178
4080
|
#
|
4179
|
-
#
|
4081
|
+
# A sample metal controller might look like this:
|
4180
4082
|
#
|
4181
|
-
#
|
4083
|
+
# class HelloController < ActionController::Metal
|
4084
|
+
# def index
|
4085
|
+
# self.response_body = "Hello World!"
|
4086
|
+
# end
|
4087
|
+
# end
|
4182
4088
|
#
|
4183
|
-
#
|
4089
|
+
# And then to route requests to your metal controller, you would add
|
4090
|
+
# something like this to <tt>config/routes.rb</tt>:
|
4184
4091
|
#
|
4185
|
-
#
|
4092
|
+
# get 'hello', to: HelloController.action(:index)
|
4186
4093
|
#
|
4187
|
-
#
|
4094
|
+
# The +action+ method returns a valid Rack application for the \Rails
|
4095
|
+
# router to dispatch to.
|
4188
4096
|
#
|
4189
|
-
#
|
4190
|
-
# For example:
|
4097
|
+
# == Rendering Helpers
|
4191
4098
|
#
|
4192
|
-
#
|
4099
|
+
# <tt>ActionController::Metal</tt> by default provides no utilities for rendering
|
4100
|
+
# views, partials, or other responses aside from explicitly calling of
|
4101
|
+
# <tt>response_body=</tt>, <tt>content_type=</tt>, and <tt>status=</tt>. To
|
4102
|
+
# add the render helpers you're used to having in a normal controller, you
|
4103
|
+
# can do the following:
|
4193
4104
|
#
|
4194
|
-
#
|
4195
|
-
#
|
4105
|
+
# class HelloController < ActionController::Metal
|
4106
|
+
# include AbstractController::Rendering
|
4107
|
+
# include ActionView::Layouts
|
4108
|
+
# append_view_path "#{Rails.root}/app/views"
|
4196
4109
|
#
|
4197
|
-
#
|
4110
|
+
# def index
|
4111
|
+
# render "hello/index"
|
4112
|
+
# end
|
4113
|
+
# end
|
4198
4114
|
#
|
4199
|
-
#
|
4115
|
+
# == Redirection Helpers
|
4200
4116
|
#
|
4201
|
-
#
|
4117
|
+
# To add redirection helpers to your metal controller, do the following:
|
4202
4118
|
#
|
4203
|
-
#
|
4119
|
+
# class HelloController < ActionController::Metal
|
4120
|
+
# include ActionController::Redirecting
|
4121
|
+
# include Rails.application.routes.url_helpers
|
4122
|
+
#
|
4123
|
+
# def index
|
4124
|
+
# redirect_to root_url
|
4125
|
+
# end
|
4126
|
+
# end
|
4127
|
+
#
|
4128
|
+
# == Other Helpers
|
4129
|
+
#
|
4130
|
+
# You can refer to the modules included in <tt>ActionController::Base</tt> to see
|
4131
|
+
# other features you can bring into your metal controller.
|
4132
|
+
#
|
4133
|
+
class Metal < AbstractController::Base
|
4134
|
+
# Returns the last part of the controller's name, underscored, without the ending
|
4135
|
+
# <tt>Controller</tt>. For instance, PostsController returns <tt>posts</tt>.
|
4136
|
+
# Namespaces are left out, so Admin::PostsController returns <tt>posts</tt> as well.
|
4137
|
+
#
|
4138
|
+
# ==== Returns
|
4139
|
+
# * <tt>string</tt>
|
4140
|
+
def self.controller_name: () -> untyped
|
4141
|
+
|
4142
|
+
def self.make_response!: (untyped request) -> untyped
|
4143
|
+
|
4144
|
+
def self.binary_params_for?: (untyped action) -> ::FalseClass
|
4145
|
+
|
4146
|
+
# Delegates to the class' <tt>controller_name</tt>.
|
4147
|
+
def controller_name: () -> untyped
|
4148
|
+
|
4149
|
+
def initialize: () -> untyped
|
4150
|
+
|
4151
|
+
def params: () -> untyped
|
4152
|
+
|
4153
|
+
def params=: (untyped val) -> untyped
|
4154
|
+
|
4155
|
+
alias response_code status
|
4156
|
+
|
4157
|
+
# Basic url_for that can be overridden for more robust functionality.
|
4158
|
+
def url_for: (untyped string) -> untyped
|
4159
|
+
|
4160
|
+
def response_body=: (untyped body) -> (nil | untyped)
|
4161
|
+
|
4162
|
+
# Tests if render or redirect has already happened.
|
4163
|
+
def performed?: () -> untyped
|
4164
|
+
|
4165
|
+
def dispatch: (untyped name, untyped request, untyped response) -> untyped
|
4166
|
+
|
4167
|
+
def set_response!: (untyped response) -> untyped
|
4168
|
+
|
4169
|
+
def set_request!: (untyped request) -> untyped
|
4170
|
+
|
4171
|
+
def to_a: () -> untyped
|
4172
|
+
|
4173
|
+
def reset_session: () -> untyped
|
4174
|
+
|
4175
|
+
def self.inherited: (untyped base) -> untyped
|
4176
|
+
|
4177
|
+
# Pushes the given Rack middleware and its arguments to the bottom of the
|
4178
|
+
# middleware stack.
|
4179
|
+
def self.use: (*untyped args) { () -> untyped } -> untyped
|
4180
|
+
|
4181
|
+
# Alias for +middleware_stack+.
|
4182
|
+
def self.middleware: () -> untyped
|
4183
|
+
|
4184
|
+
# Returns a Rack endpoint for the given action name.
|
4185
|
+
def self.action: (untyped name) -> untyped
|
4186
|
+
|
4187
|
+
# Direct dispatch to the controller. Instantiates the controller, then
|
4188
|
+
# executes the action named +name+.
|
4189
|
+
def self.dispatch: (untyped name, untyped req, untyped res) -> untyped
|
4190
|
+
end
|
4191
|
+
end
|
4192
|
+
|
4193
|
+
module ActionController
|
4194
|
+
class Railtie < Rails::Railtie
|
4195
|
+
extend ::ActionController::Railties::Helpers
|
4196
|
+
end
|
4197
|
+
end
|
4198
|
+
|
4199
|
+
module ActionController
|
4200
|
+
module Railties
|
4201
|
+
module Helpers
|
4202
|
+
def inherited: (untyped klass) -> (nil | untyped)
|
4203
|
+
end
|
4204
|
+
end
|
4205
|
+
end
|
4206
|
+
|
4207
|
+
module ActionController
|
4208
|
+
# ActionController::Renderer allows you to render arbitrary templates
|
4209
|
+
# without requirement of being in controller actions.
|
4210
|
+
#
|
4211
|
+
# You get a concrete renderer class by invoking ActionController::Base#renderer.
|
4212
|
+
# For example:
|
4213
|
+
#
|
4214
|
+
# ApplicationController.renderer
|
4215
|
+
#
|
4216
|
+
# It allows you to call method #render directly.
|
4217
|
+
#
|
4218
|
+
# ApplicationController.renderer.render template: '...'
|
4219
|
+
#
|
4220
|
+
# You can use this shortcut in a controller, instead of the previous example:
|
4221
|
+
#
|
4222
|
+
# ApplicationController.render template: '...'
|
4223
|
+
#
|
4224
|
+
# #render allows you to use the same options that you can use when rendering in a controller.
|
4225
|
+
# For example:
|
4226
|
+
#
|
4227
|
+
# FooController.render :action, locals: { ... }, assigns: { ... }
|
4228
|
+
#
|
4229
|
+
# The template will be rendered in a Rack environment which is accessible through
|
4230
|
+
# ActionController::Renderer#env. You can set it up in two ways:
|
4231
|
+
#
|
4232
|
+
# * by changing renderer defaults, like
|
4233
|
+
#
|
4234
|
+
# ApplicationController.renderer.defaults # => hash with default Rack environment
|
4235
|
+
#
|
4236
|
+
# * by initializing an instance of renderer by passing it a custom environment.
|
4237
|
+
#
|
4238
|
+
# ApplicationController.renderer.new(method: 'post', https: true)
|
4204
4239
|
#
|
4205
4240
|
class Renderer
|
4206
4241
|
attr_reader defaults: untyped
|
@@ -4267,6 +4302,10 @@ module ActionController
|
|
4267
4302
|
include Testing::Functional
|
4268
4303
|
end
|
4269
4304
|
|
4305
|
+
module Live
|
4306
|
+
def new_controller_thread: () { () -> untyped } -> untyped
|
4307
|
+
end
|
4308
|
+
|
4270
4309
|
class TestRequest < ActionDispatch::TestRequest
|
4271
4310
|
# ActionController::TestCase will be deprecated and moved to a gem in the future.
|
4272
4311
|
# Please use ActionDispatch::IntegrationTest going forward.
|
@@ -4296,6 +4335,14 @@ module ActionController
|
|
4296
4335
|
end
|
4297
4336
|
|
4298
4337
|
class LiveTestResponse < Live::Response
|
4338
|
+
# Was the response successful?
|
4339
|
+
alias success? successful?
|
4340
|
+
|
4341
|
+
# Was the URL not found?
|
4342
|
+
alias missing? not_found?
|
4343
|
+
|
4344
|
+
# Was there a server-side error?
|
4345
|
+
alias error? server_error?
|
4299
4346
|
end
|
4300
4347
|
|
4301
4348
|
class TestSession < Rack::Session::Abstract::PersistedSecure::SecureSessionHash
|
@@ -4562,6 +4609,10 @@ module ActionController
|
|
4562
4609
|
end
|
4563
4610
|
end
|
4564
4611
|
|
4612
|
+
module ActionController
|
4613
|
+
extend ActiveSupport::Autoload
|
4614
|
+
end
|
4615
|
+
|
4565
4616
|
module ActionDispatch
|
4566
4617
|
module Http
|
4567
4618
|
module Cache
|
@@ -4902,6 +4953,8 @@ module ActionDispatch
|
|
4902
4953
|
|
4903
4954
|
def key?: (untyped key) -> untyped
|
4904
4955
|
|
4956
|
+
alias include? key?
|
4957
|
+
|
4905
4958
|
DEFAULT: untyped
|
4906
4959
|
|
4907
4960
|
# Returns the value for the given key mapped to @env.
|
@@ -5062,6 +5115,8 @@ module Mime
|
|
5062
5115
|
# nodoc:
|
5063
5116
|
attr_accessor q: untyped
|
5064
5117
|
|
5118
|
+
alias to_s name
|
5119
|
+
|
5065
5120
|
def initialize: (untyped index, untyped name, ?untyped? q) -> untyped
|
5066
5121
|
|
5067
5122
|
def <=>: (untyped item) -> untyped
|
@@ -5226,6 +5281,8 @@ module ActionDispatch
|
|
5226
5281
|
# Returns both GET and POST \parameters in a single hash.
|
5227
5282
|
def parameters: () -> untyped
|
5228
5283
|
|
5284
|
+
alias params parameters
|
5285
|
+
|
5229
5286
|
def path_parameters=: (untyped parameters) -> untyped
|
5230
5287
|
|
5231
5288
|
# Returns a hash with the \parameters used to form the \path of the request.
|
@@ -5305,6 +5362,8 @@ module ActionDispatch
|
|
5305
5362
|
|
5306
5363
|
def initialize: (untyped env) -> untyped
|
5307
5364
|
|
5365
|
+
def commit_cookie_jar!: () -> nil
|
5366
|
+
|
5308
5367
|
PASS_NOT_FOUND: untyped
|
5309
5368
|
|
5310
5369
|
def controller_class: () -> untyped
|
@@ -5438,6 +5497,8 @@ module ActionDispatch
|
|
5438
5497
|
# choice of JavaScript libraries and frameworks.
|
5439
5498
|
def xml_http_request?: () -> untyped
|
5440
5499
|
|
5500
|
+
alias xhr? xml_http_request?
|
5501
|
+
|
5441
5502
|
# Returns the IP address of client as a +String+.
|
5442
5503
|
def ip: () -> untyped
|
5443
5504
|
|
@@ -5459,6 +5520,8 @@ module ActionDispatch
|
|
5459
5520
|
|
5460
5521
|
def request_id=: (untyped id) -> untyped
|
5461
5522
|
|
5523
|
+
alias uuid request_id
|
5524
|
+
|
5462
5525
|
# Returns the lowercase name of the HTTP server software.
|
5463
5526
|
def server_software: () -> untyped
|
5464
5527
|
|
@@ -5493,9 +5556,13 @@ module ActionDispatch
|
|
5493
5556
|
# Override Rack's GET method to support indifferent access.
|
5494
5557
|
def GET: () -> untyped
|
5495
5558
|
|
5559
|
+
alias query_parameters GET
|
5560
|
+
|
5496
5561
|
# Override Rack's POST method to support indifferent access.
|
5497
5562
|
def POST: () -> untyped
|
5498
5563
|
|
5564
|
+
alias request_parameters POST
|
5565
|
+
|
5499
5566
|
# Returns the authorization header regardless of whether it was specified directly or through one of the
|
5500
5567
|
# proxy alternatives.
|
5501
5568
|
def authorization: () -> untyped
|
@@ -5546,7 +5613,6 @@ module ActionDispatch
|
|
5546
5613
|
# end
|
5547
5614
|
# end
|
5548
5615
|
class Response
|
5549
|
-
# Note: It inherits unnamed class, but omitted^
|
5550
5616
|
class Header
|
5551
5617
|
# :nodoc:
|
5552
5618
|
def initialize: (untyped response, untyped header) -> untyped
|
@@ -5567,6 +5633,8 @@ module ActionDispatch
|
|
5567
5633
|
# Get headers for this response.
|
5568
5634
|
attr_reader header: untyped
|
5569
5635
|
|
5636
|
+
alias headers header
|
5637
|
+
|
5570
5638
|
def each: () { () -> untyped } -> untyped
|
5571
5639
|
|
5572
5640
|
CONTENT_TYPE: ::String
|
@@ -5579,6 +5647,11 @@ module ActionDispatch
|
|
5579
5647
|
|
5580
5648
|
include Rack::Response::Helpers
|
5581
5649
|
|
5650
|
+
# Aliasing these off because AD::Http::Cache::Response defines them.
|
5651
|
+
alias _cache_control cache_control
|
5652
|
+
|
5653
|
+
alias _cache_control= cache_control=
|
5654
|
+
|
5582
5655
|
include ActionDispatch::Http::FilterRedirect
|
5583
5656
|
|
5584
5657
|
include ActionDispatch::Http::Cache::Response
|
@@ -5685,6 +5758,8 @@ module ActionDispatch
|
|
5685
5758
|
#
|
5686
5759
|
def message: () -> untyped
|
5687
5760
|
|
5761
|
+
alias status_message message
|
5762
|
+
|
5688
5763
|
# Returns the content of the response as a string. This contains the contents
|
5689
5764
|
# of any calls to <tt>render</tt>.
|
5690
5765
|
def body: () -> untyped
|
@@ -5716,6 +5791,9 @@ module ActionDispatch
|
|
5716
5791
|
|
5717
5792
|
def body_parts: () -> untyped
|
5718
5793
|
|
5794
|
+
# The location header we'll be responding with.
|
5795
|
+
alias redirect_url location
|
5796
|
+
|
5719
5797
|
def close: () -> untyped
|
5720
5798
|
|
5721
5799
|
def abort: () -> untyped
|
@@ -5726,6 +5804,8 @@ module ActionDispatch
|
|
5726
5804
|
# status, headers, body = *response
|
5727
5805
|
def to_a: () -> untyped
|
5728
5806
|
|
5807
|
+
alias prepare! to_a
|
5808
|
+
|
5729
5809
|
# Returns the response cookies, converted to a Hash of (name => value) pairs
|
5730
5810
|
#
|
5731
5811
|
# assert_equal 'AuthorOfNewPage', r.cookies['author']
|
@@ -6224,6 +6304,10 @@ module ActionDispatch
|
|
6224
6304
|
def initialize: (untyped transition_table) -> untyped
|
6225
6305
|
|
6226
6306
|
def simulate: (untyped string) -> (nil | MatchData)
|
6307
|
+
|
6308
|
+
alias =~ simulate
|
6309
|
+
|
6310
|
+
alias match simulate
|
6227
6311
|
end
|
6228
6312
|
end
|
6229
6313
|
end
|
@@ -6321,6 +6405,9 @@ module ActionDispatch
|
|
6321
6405
|
end
|
6322
6406
|
|
6323
6407
|
class Terminal < Node
|
6408
|
+
# :nodoc:
|
6409
|
+
alias symbol left
|
6410
|
+
|
6324
6411
|
def terminal?: () -> ::TrueClass
|
6325
6412
|
end
|
6326
6413
|
|
@@ -6352,6 +6439,8 @@ module ActionDispatch
|
|
6352
6439
|
# :nodoc:
|
6353
6440
|
attr_accessor regexp: untyped
|
6354
6441
|
|
6442
|
+
alias symbol regexp
|
6443
|
+
|
6355
6444
|
attr_reader name: untyped
|
6356
6445
|
|
6357
6446
|
DEFAULT_EXP: untyped
|
@@ -6414,23 +6503,6 @@ module ActionDispatch
|
|
6414
6503
|
end
|
6415
6504
|
end
|
6416
6505
|
|
6417
|
-
module ActionDispatch
|
6418
|
-
# :stopdoc:
|
6419
|
-
module Journey
|
6420
|
-
class Parser < Racc::Parser
|
6421
|
-
include Journey::Nodes
|
6422
|
-
|
6423
|
-
def self.parse: (untyped string) -> untyped
|
6424
|
-
|
6425
|
-
def initialize: () -> untyped
|
6426
|
-
|
6427
|
-
def parse: (untyped string) -> untyped
|
6428
|
-
|
6429
|
-
def next_token: () -> untyped
|
6430
|
-
end
|
6431
|
-
end
|
6432
|
-
end
|
6433
|
-
|
6434
6506
|
module ActionDispatch
|
6435
6507
|
module Journey
|
6436
6508
|
class Parser < Racc::Parser
|
@@ -6465,6 +6537,23 @@ module ActionDispatch
|
|
6465
6537
|
end
|
6466
6538
|
end
|
6467
6539
|
|
6540
|
+
module ActionDispatch
|
6541
|
+
# :stopdoc:
|
6542
|
+
module Journey
|
6543
|
+
class Parser < Racc::Parser
|
6544
|
+
include Journey::Nodes
|
6545
|
+
|
6546
|
+
def self.parse: (untyped string) -> untyped
|
6547
|
+
|
6548
|
+
def initialize: () -> untyped
|
6549
|
+
|
6550
|
+
def parse: (untyped string) -> untyped
|
6551
|
+
|
6552
|
+
def next_token: () -> untyped
|
6553
|
+
end
|
6554
|
+
end
|
6555
|
+
end
|
6556
|
+
|
6468
6557
|
module ActionDispatch
|
6469
6558
|
module Journey
|
6470
6559
|
module Path
|
@@ -6516,6 +6605,8 @@ module ActionDispatch
|
|
6516
6605
|
|
6517
6606
|
def visit_LITERAL: (untyped node) -> untyped
|
6518
6607
|
|
6608
|
+
alias visit_DOT visit_LITERAL
|
6609
|
+
|
6519
6610
|
def visit_SLASH: (untyped node) -> untyped
|
6520
6611
|
|
6521
6612
|
def visit_STAR: (untyped node) -> ::String
|
@@ -6549,6 +6640,8 @@ module ActionDispatch
|
|
6549
6640
|
|
6550
6641
|
def match: (untyped other) -> (nil | MatchData)
|
6551
6642
|
|
6643
|
+
alias =~ match
|
6644
|
+
|
6552
6645
|
def source: () -> untyped
|
6553
6646
|
|
6554
6647
|
def to_regexp: () -> untyped
|
@@ -6581,6 +6674,8 @@ module ActionDispatch
|
|
6581
6674
|
|
6582
6675
|
attr_reader scope_options: untyped
|
6583
6676
|
|
6677
|
+
alias conditions constraints
|
6678
|
+
|
6584
6679
|
module VerbMatchers
|
6585
6680
|
VERBS: ::Array[untyped]
|
6586
6681
|
|
@@ -6632,6 +6727,8 @@ module ActionDispatch
|
|
6632
6727
|
|
6633
6728
|
def parts: () -> untyped
|
6634
6729
|
|
6730
|
+
alias segment_keys parts
|
6731
|
+
|
6635
6732
|
def format: (untyped path_options) -> untyped
|
6636
6733
|
|
6637
6734
|
def required_parts: () -> untyped
|
@@ -6659,42 +6756,6 @@ module ActionDispatch
|
|
6659
6756
|
end
|
6660
6757
|
end
|
6661
6758
|
|
6662
|
-
module ActionDispatch
|
6663
|
-
module Journey
|
6664
|
-
class Router
|
6665
|
-
# :nodoc:
|
6666
|
-
# :nodoc:
|
6667
|
-
attr_accessor routes: untyped
|
6668
|
-
|
6669
|
-
def initialize: (untyped routes) -> untyped
|
6670
|
-
|
6671
|
-
def eager_load!: () -> nil
|
6672
|
-
|
6673
|
-
def serve: (untyped req) -> (::Array[untyped] | ::Array[404 | ::Hash[::String, "pass"] | ::Array["Not Found"]])
|
6674
|
-
|
6675
|
-
def recognize: (untyped rails_req) { (untyped, untyped) -> untyped } -> untyped
|
6676
|
-
|
6677
|
-
def visualizer: () -> untyped
|
6678
|
-
|
6679
|
-
def partitioned_routes: () -> untyped
|
6680
|
-
|
6681
|
-
def ast: () -> untyped
|
6682
|
-
|
6683
|
-
def simulator: () -> untyped
|
6684
|
-
|
6685
|
-
def custom_routes: () -> untyped
|
6686
|
-
|
6687
|
-
def filter_routes: (untyped path) -> (::Array[untyped] | untyped)
|
6688
|
-
|
6689
|
-
def find_routes: (untyped req) -> untyped
|
6690
|
-
|
6691
|
-
def match_head_routes: (untyped routes, untyped req) -> untyped
|
6692
|
-
|
6693
|
-
def match_routes: (untyped routes, untyped req) -> untyped
|
6694
|
-
end
|
6695
|
-
end
|
6696
|
-
end
|
6697
|
-
|
6698
6759
|
module ActionDispatch
|
6699
6760
|
module Journey
|
6700
6761
|
class Router
|
@@ -6777,40 +6838,78 @@ end
|
|
6777
6838
|
|
6778
6839
|
module ActionDispatch
|
6779
6840
|
module Journey
|
6780
|
-
class
|
6841
|
+
class Router
|
6781
6842
|
# :nodoc:
|
6782
|
-
# The Routing table. Contains all routes for a system. Routes can be
|
6783
|
-
# added to the table by calling Routes#add_route.
|
6784
6843
|
# :nodoc:
|
6785
|
-
|
6786
|
-
|
6787
|
-
attr_reader routes: untyped
|
6844
|
+
attr_accessor routes: untyped
|
6788
6845
|
|
6789
|
-
|
6846
|
+
def initialize: (untyped routes) -> untyped
|
6790
6847
|
|
6791
|
-
|
6848
|
+
def eager_load!: () -> nil
|
6792
6849
|
|
6793
|
-
def
|
6850
|
+
def serve: (untyped req) -> (::Array[untyped] | ::Array[404 | ::Hash[::String, "pass"] | ::Array["Not Found"]])
|
6794
6851
|
|
6795
|
-
def
|
6852
|
+
def recognize: (untyped rails_req) { (untyped, untyped) -> untyped } -> untyped
|
6796
6853
|
|
6797
|
-
def
|
6854
|
+
def visualizer: () -> untyped
|
6798
6855
|
|
6799
|
-
def
|
6856
|
+
def partitioned_routes: () -> untyped
|
6800
6857
|
|
6801
|
-
def
|
6858
|
+
def ast: () -> untyped
|
6802
6859
|
|
6803
|
-
def
|
6860
|
+
def simulator: () -> untyped
|
6804
6861
|
|
6805
|
-
def
|
6862
|
+
def custom_routes: () -> untyped
|
6806
6863
|
|
6807
|
-
def
|
6864
|
+
def filter_routes: (untyped path) -> (::Array[untyped] | untyped)
|
6808
6865
|
|
6809
|
-
def
|
6866
|
+
def find_routes: (untyped req) -> untyped
|
6810
6867
|
|
6811
|
-
def
|
6868
|
+
def match_head_routes: (untyped routes, untyped req) -> untyped
|
6812
6869
|
|
6813
|
-
def
|
6870
|
+
def match_routes: (untyped routes, untyped req) -> untyped
|
6871
|
+
end
|
6872
|
+
end
|
6873
|
+
end
|
6874
|
+
|
6875
|
+
module ActionDispatch
|
6876
|
+
module Journey
|
6877
|
+
class Routes
|
6878
|
+
# :nodoc:
|
6879
|
+
# The Routing table. Contains all routes for a system. Routes can be
|
6880
|
+
# added to the table by calling Routes#add_route.
|
6881
|
+
# :nodoc:
|
6882
|
+
include Enumerable[untyped, untyped]
|
6883
|
+
|
6884
|
+
attr_reader routes: untyped
|
6885
|
+
|
6886
|
+
attr_reader custom_routes: untyped
|
6887
|
+
|
6888
|
+
attr_reader anchored_routes: untyped
|
6889
|
+
|
6890
|
+
def initialize: () -> untyped
|
6891
|
+
|
6892
|
+
def empty?: () -> untyped
|
6893
|
+
|
6894
|
+
def length: () -> untyped
|
6895
|
+
|
6896
|
+
alias size length
|
6897
|
+
|
6898
|
+
def last: () -> untyped
|
6899
|
+
|
6900
|
+
def each: () { () -> untyped } -> untyped
|
6901
|
+
|
6902
|
+
def clear: () -> untyped
|
6903
|
+
|
6904
|
+
def partition_route: (untyped route) -> untyped
|
6905
|
+
|
6906
|
+
def ast: () -> untyped
|
6907
|
+
|
6908
|
+
def simulator: () -> untyped
|
6909
|
+
|
6910
|
+
def add_route: (untyped name, untyped mapping) -> untyped
|
6911
|
+
|
6912
|
+
def clear_cache!: () -> untyped
|
6814
6913
|
end
|
6815
6914
|
end
|
6816
6915
|
end
|
@@ -7277,6 +7376,11 @@ module ActionDispatch
|
|
7277
7376
|
|
7278
7377
|
def key?: (untyped name) -> untyped
|
7279
7378
|
|
7379
|
+
alias has_key? key?
|
7380
|
+
|
7381
|
+
# Returns the cookies as Hash.
|
7382
|
+
alias to_hash to_h
|
7383
|
+
|
7280
7384
|
def update: (untyped other_hash) -> untyped
|
7281
7385
|
|
7282
7386
|
def update_cookies_from_jar: () -> untyped
|
@@ -7641,6 +7745,8 @@ module ActionDispatch
|
|
7641
7745
|
|
7642
7746
|
def each: () { () -> untyped } -> untyped
|
7643
7747
|
|
7748
|
+
alias merge! update
|
7749
|
+
|
7644
7750
|
def replace: (untyped h) -> untyped
|
7645
7751
|
|
7646
7752
|
# Sets a flash that will not be available to the next action, only to the current.
|
@@ -8024,8 +8130,8 @@ module ActionDispatch
|
|
8024
8130
|
# Other useful options include <tt>:key</tt>, <tt>:secure</tt> and
|
8025
8131
|
# <tt>:httponly</tt>.
|
8026
8132
|
class CookieStore < AbstractSecureStore
|
8027
|
-
# Note: It inherits unnamed class, but omitted^
|
8028
8133
|
class SessionId
|
8134
|
+
# Note: It inherits unnamed class, but omitted
|
8029
8135
|
attr_reader cookie_value: untyped
|
8030
8136
|
|
8031
8137
|
def initialize: (untyped session_id, ?::Hash[untyped, untyped] cookie_value) -> untyped
|
@@ -8224,6 +8330,8 @@ module ActionDispatch
|
|
8224
8330
|
|
8225
8331
|
def insert: (untyped index, untyped klass, *untyped args) { () -> untyped } -> untyped
|
8226
8332
|
|
8333
|
+
alias insert_before insert
|
8334
|
+
|
8227
8335
|
def insert_after: (untyped index, *untyped args) { () -> untyped } -> untyped
|
8228
8336
|
|
8229
8337
|
def swap: (untyped target, *untyped args) { () -> untyped } -> untyped
|
@@ -8296,26 +8404,6 @@ module ActionDispatch
|
|
8296
8404
|
end
|
8297
8405
|
end
|
8298
8406
|
|
8299
|
-
module Rack
|
8300
|
-
end
|
8301
|
-
|
8302
|
-
module ActionDispatch
|
8303
|
-
extend ActiveSupport::Autoload
|
8304
|
-
|
8305
|
-
class IllegalStateError < StandardError
|
8306
|
-
end
|
8307
|
-
|
8308
|
-
class MissingController[T] < NameError[T]
|
8309
|
-
end
|
8310
|
-
|
8311
|
-
module Http
|
8312
|
-
extend ActiveSupport::Autoload
|
8313
|
-
end
|
8314
|
-
|
8315
|
-
module Session
|
8316
|
-
end
|
8317
|
-
end
|
8318
|
-
|
8319
8407
|
module ActionDispatch
|
8320
8408
|
class Request
|
8321
8409
|
class Session
|
@@ -8371,6 +8459,10 @@ module ActionDispatch
|
|
8371
8459
|
# Returns true if the session has the given key or false.
|
8372
8460
|
def has_key?: (untyped key) -> untyped
|
8373
8461
|
|
8462
|
+
alias key? has_key?
|
8463
|
+
|
8464
|
+
alias include? has_key?
|
8465
|
+
|
8374
8466
|
# Returns keys of the session as Array.
|
8375
8467
|
def keys: () -> untyped
|
8376
8468
|
|
@@ -8386,6 +8478,8 @@ module ActionDispatch
|
|
8386
8478
|
# Returns the session as Hash.
|
8387
8479
|
def to_hash: () -> untyped
|
8388
8480
|
|
8481
|
+
alias to_h to_hash
|
8482
|
+
|
8389
8483
|
# Updates the session with given Hash.
|
8390
8484
|
#
|
8391
8485
|
# session.to_hash
|
@@ -8906,6 +9000,8 @@ module ActionDispatch
|
|
8906
9000
|
|
8907
9001
|
def default_url_options=: (untyped options) -> untyped
|
8908
9002
|
|
9003
|
+
alias default_url_options default_url_options=
|
9004
|
+
|
8909
9005
|
def with_default_scope: (untyped scope) { () -> untyped } -> untyped
|
8910
9006
|
|
8911
9007
|
# Query if the following named route was already defined.
|
@@ -9257,14 +9353,20 @@ module ActionDispatch
|
|
9257
9353
|
|
9258
9354
|
def singular: () -> untyped
|
9259
9355
|
|
9356
|
+
alias member_name singular
|
9357
|
+
|
9260
9358
|
# Checks for uncountable plurals, and appends "_index" if the plural
|
9261
9359
|
# and singular form are the same.
|
9262
9360
|
def collection_name: () -> untyped
|
9263
9361
|
|
9264
9362
|
def resource_scope: () -> untyped
|
9265
9363
|
|
9364
|
+
alias collection_scope path
|
9365
|
+
|
9266
9366
|
def member_scope: () -> ::String
|
9267
9367
|
|
9368
|
+
alias shallow_scope member_scope
|
9369
|
+
|
9268
9370
|
def new_scope: (untyped new_path) -> ::String
|
9269
9371
|
|
9270
9372
|
def nested_param: () -> ::Symbol
|
@@ -9286,6 +9388,14 @@ module ActionDispatch
|
|
9286
9388
|
|
9287
9389
|
def singular: () -> untyped
|
9288
9390
|
|
9391
|
+
alias member_name singular
|
9392
|
+
|
9393
|
+
alias collection_name singular
|
9394
|
+
|
9395
|
+
alias member_scope path
|
9396
|
+
|
9397
|
+
alias nested_scope path
|
9398
|
+
|
9289
9399
|
def singleton?: () -> ::TrueClass
|
9290
9400
|
end
|
9291
9401
|
|
@@ -9984,259 +10094,6 @@ module ActionDispatch
|
|
9984
10094
|
end
|
9985
10095
|
end
|
9986
10096
|
|
9987
|
-
module ActionDispatch
|
9988
|
-
# The routing module provides URL rewriting in native Ruby. It's a way to
|
9989
|
-
# redirect incoming requests to controllers and actions. This replaces
|
9990
|
-
# mod_rewrite rules. Best of all, Rails' \Routing works with any web server.
|
9991
|
-
# Routes are defined in <tt>config/routes.rb</tt>.
|
9992
|
-
#
|
9993
|
-
# Think of creating routes as drawing a map for your requests. The map tells
|
9994
|
-
# them where to go based on some predefined pattern:
|
9995
|
-
#
|
9996
|
-
# Rails.application.routes.draw do
|
9997
|
-
# Pattern 1 tells some request to go to one place
|
9998
|
-
# Pattern 2 tell them to go to another
|
9999
|
-
# ...
|
10000
|
-
# end
|
10001
|
-
#
|
10002
|
-
# The following symbols are special:
|
10003
|
-
#
|
10004
|
-
# :controller maps to your controller name
|
10005
|
-
# :action maps to an action with your controllers
|
10006
|
-
#
|
10007
|
-
# Other names simply map to a parameter as in the case of <tt>:id</tt>.
|
10008
|
-
#
|
10009
|
-
# == Resources
|
10010
|
-
#
|
10011
|
-
# Resource routing allows you to quickly declare all of the common routes
|
10012
|
-
# for a given resourceful controller. Instead of declaring separate routes
|
10013
|
-
# for your +index+, +show+, +new+, +edit+, +create+, +update+ and +destroy+
|
10014
|
-
# actions, a resourceful route declares them in a single line of code:
|
10015
|
-
#
|
10016
|
-
# resources :photos
|
10017
|
-
#
|
10018
|
-
# Sometimes, you have a resource that clients always look up without
|
10019
|
-
# referencing an ID. A common example, /profile always shows the profile of
|
10020
|
-
# the currently logged in user. In this case, you can use a singular resource
|
10021
|
-
# to map /profile (rather than /profile/:id) to the show action.
|
10022
|
-
#
|
10023
|
-
# resource :profile
|
10024
|
-
#
|
10025
|
-
# It's common to have resources that are logically children of other
|
10026
|
-
# resources:
|
10027
|
-
#
|
10028
|
-
# resources :magazines do
|
10029
|
-
# resources :ads
|
10030
|
-
# end
|
10031
|
-
#
|
10032
|
-
# You may wish to organize groups of controllers under a namespace. Most
|
10033
|
-
# commonly, you might group a number of administrative controllers under
|
10034
|
-
# an +admin+ namespace. You would place these controllers under the
|
10035
|
-
# <tt>app/controllers/admin</tt> directory, and you can group them together
|
10036
|
-
# in your router:
|
10037
|
-
#
|
10038
|
-
# namespace "admin" do
|
10039
|
-
# resources :posts, :comments
|
10040
|
-
# end
|
10041
|
-
#
|
10042
|
-
# Alternatively, you can add prefixes to your path without using a separate
|
10043
|
-
# directory by using +scope+. +scope+ takes additional options which
|
10044
|
-
# apply to all enclosed routes.
|
10045
|
-
#
|
10046
|
-
# scope path: "/cpanel", as: 'admin' do
|
10047
|
-
# resources :posts, :comments
|
10048
|
-
# end
|
10049
|
-
#
|
10050
|
-
# For more, see <tt>Routing::Mapper::Resources#resources</tt>,
|
10051
|
-
# <tt>Routing::Mapper::Scoping#namespace</tt>, and
|
10052
|
-
# <tt>Routing::Mapper::Scoping#scope</tt>.
|
10053
|
-
#
|
10054
|
-
# == Non-resourceful routes
|
10055
|
-
#
|
10056
|
-
# For routes that don't fit the <tt>resources</tt> mold, you can use the HTTP helper
|
10057
|
-
# methods <tt>get</tt>, <tt>post</tt>, <tt>patch</tt>, <tt>put</tt> and <tt>delete</tt>.
|
10058
|
-
#
|
10059
|
-
# get 'post/:id', to: 'posts#show'
|
10060
|
-
# post 'post/:id', to: 'posts#create_comment'
|
10061
|
-
#
|
10062
|
-
# Now, if you POST to <tt>/posts/:id</tt>, it will route to the <tt>create_comment</tt> action. A GET on the same
|
10063
|
-
# URL will route to the <tt>show</tt> action.
|
10064
|
-
#
|
10065
|
-
# If your route needs to respond to more than one HTTP method (or all methods) then using the
|
10066
|
-
# <tt>:via</tt> option on <tt>match</tt> is preferable.
|
10067
|
-
#
|
10068
|
-
# match 'post/:id', to: 'posts#show', via: [:get, :post]
|
10069
|
-
#
|
10070
|
-
# == Named routes
|
10071
|
-
#
|
10072
|
-
# Routes can be named by passing an <tt>:as</tt> option,
|
10073
|
-
# allowing for easy reference within your source as +name_of_route_url+
|
10074
|
-
# for the full URL and +name_of_route_path+ for the URI path.
|
10075
|
-
#
|
10076
|
-
# Example:
|
10077
|
-
#
|
10078
|
-
# # In config/routes.rb
|
10079
|
-
# get '/login', to: 'accounts#login', as: 'login'
|
10080
|
-
#
|
10081
|
-
# # With render, redirect_to, tests, etc.
|
10082
|
-
# redirect_to login_url
|
10083
|
-
#
|
10084
|
-
# Arguments can be passed as well.
|
10085
|
-
#
|
10086
|
-
# redirect_to show_item_path(id: 25)
|
10087
|
-
#
|
10088
|
-
# Use <tt>root</tt> as a shorthand to name a route for the root path "/".
|
10089
|
-
#
|
10090
|
-
# # In config/routes.rb
|
10091
|
-
# root to: 'blogs#index'
|
10092
|
-
#
|
10093
|
-
# # would recognize http://www.example.com/ as
|
10094
|
-
# params = { controller: 'blogs', action: 'index' }
|
10095
|
-
#
|
10096
|
-
# # and provide these named routes
|
10097
|
-
# root_url # => 'http://www.example.com/'
|
10098
|
-
# root_path # => '/'
|
10099
|
-
#
|
10100
|
-
# Note: when using +controller+, the route is simply named after the
|
10101
|
-
# method you call on the block parameter rather than map.
|
10102
|
-
#
|
10103
|
-
# # In config/routes.rb
|
10104
|
-
# controller :blog do
|
10105
|
-
# get 'blog/show', to: :list
|
10106
|
-
# get 'blog/delete', to: :delete
|
10107
|
-
# get 'blog/edit', to: :edit
|
10108
|
-
# end
|
10109
|
-
#
|
10110
|
-
# # provides named routes for show, delete, and edit
|
10111
|
-
# link_to @article.title, blog_show_path(id: @article.id)
|
10112
|
-
#
|
10113
|
-
# == Pretty URLs
|
10114
|
-
#
|
10115
|
-
# Routes can generate pretty URLs. For example:
|
10116
|
-
#
|
10117
|
-
# get '/articles/:year/:month/:day', to: 'articles#find_by_id', constraints: {
|
10118
|
-
# year: /\d{4}/,
|
10119
|
-
# month: /\d{1,2}/,
|
10120
|
-
# day: /\d{1,2}/
|
10121
|
-
# }
|
10122
|
-
#
|
10123
|
-
# Using the route above, the URL "http://localhost:3000/articles/2005/11/06"
|
10124
|
-
# maps to
|
10125
|
-
#
|
10126
|
-
# params = {year: '2005', month: '11', day: '06'}
|
10127
|
-
#
|
10128
|
-
# == Regular Expressions and parameters
|
10129
|
-
# You can specify a regular expression to define a format for a parameter.
|
10130
|
-
#
|
10131
|
-
# controller 'geocode' do
|
10132
|
-
# get 'geocode/:postalcode', to: :show, constraints: {
|
10133
|
-
# postalcode: /\d{5}(-\d{4})?/
|
10134
|
-
# }
|
10135
|
-
# end
|
10136
|
-
#
|
10137
|
-
# Constraints can include the 'ignorecase' and 'extended syntax' regular
|
10138
|
-
# expression modifiers:
|
10139
|
-
#
|
10140
|
-
# controller 'geocode' do
|
10141
|
-
# get 'geocode/:postalcode', to: :show, constraints: {
|
10142
|
-
# postalcode: /hx\d\d\s\d[a-z]{2}/i
|
10143
|
-
# }
|
10144
|
-
# end
|
10145
|
-
#
|
10146
|
-
# controller 'geocode' do
|
10147
|
-
# get 'geocode/:postalcode', to: :show, constraints: {
|
10148
|
-
# postalcode: /# Postalcode format
|
10149
|
-
# \d{5} #Prefix
|
10150
|
-
# (-\d{4})? #Suffix
|
10151
|
-
# /x
|
10152
|
-
# }
|
10153
|
-
# end
|
10154
|
-
#
|
10155
|
-
# Using the multiline modifier will raise an +ArgumentError+.
|
10156
|
-
# Encoding regular expression modifiers are silently ignored. The
|
10157
|
-
# match will always use the default encoding or ASCII.
|
10158
|
-
#
|
10159
|
-
# == External redirects
|
10160
|
-
#
|
10161
|
-
# You can redirect any path to another path using the redirect helper in your router:
|
10162
|
-
#
|
10163
|
-
# get "/stories", to: redirect("/posts")
|
10164
|
-
#
|
10165
|
-
# == Unicode character routes
|
10166
|
-
#
|
10167
|
-
# You can specify unicode character routes in your router:
|
10168
|
-
#
|
10169
|
-
# get "(trim non-ascii characters)", to: "welcome#index"
|
10170
|
-
#
|
10171
|
-
# == Routing to Rack Applications
|
10172
|
-
#
|
10173
|
-
# Instead of a String, like <tt>posts#index</tt>, which corresponds to the
|
10174
|
-
# index action in the PostsController, you can specify any Rack application
|
10175
|
-
# as the endpoint for a matcher:
|
10176
|
-
#
|
10177
|
-
# get "/application.js", to: Sprockets
|
10178
|
-
#
|
10179
|
-
# == Reloading routes
|
10180
|
-
#
|
10181
|
-
# You can reload routes if you feel you must:
|
10182
|
-
#
|
10183
|
-
# Rails.application.reload_routes!
|
10184
|
-
#
|
10185
|
-
# This will clear all named routes and reload config/routes.rb if the file has been modified from
|
10186
|
-
# last load. To absolutely force reloading, use <tt>reload!</tt>.
|
10187
|
-
#
|
10188
|
-
# == Testing Routes
|
10189
|
-
#
|
10190
|
-
# The two main methods for testing your routes:
|
10191
|
-
#
|
10192
|
-
# === +assert_routing+
|
10193
|
-
#
|
10194
|
-
# def test_movie_route_properly_splits
|
10195
|
-
# opts = {controller: "plugin", action: "checkout", id: "2"}
|
10196
|
-
# assert_routing "plugin/checkout/2", opts
|
10197
|
-
# end
|
10198
|
-
#
|
10199
|
-
# +assert_routing+ lets you test whether or not the route properly resolves into options.
|
10200
|
-
#
|
10201
|
-
# === +assert_recognizes+
|
10202
|
-
#
|
10203
|
-
# def test_route_has_options
|
10204
|
-
# opts = {controller: "plugin", action: "show", id: "12"}
|
10205
|
-
# assert_recognizes opts, "/plugins/show/12"
|
10206
|
-
# end
|
10207
|
-
#
|
10208
|
-
# Note the subtle difference between the two: +assert_routing+ tests that
|
10209
|
-
# a URL fits options while +assert_recognizes+ tests that a URL
|
10210
|
-
# breaks into parameters properly.
|
10211
|
-
#
|
10212
|
-
# In tests you can simply pass the URL or named route to +get+ or +post+.
|
10213
|
-
#
|
10214
|
-
# def send_to_jail
|
10215
|
-
# get '/jail'
|
10216
|
-
# assert_response :success
|
10217
|
-
# end
|
10218
|
-
#
|
10219
|
-
# def goes_to_login
|
10220
|
-
# get login_url
|
10221
|
-
# #...
|
10222
|
-
# end
|
10223
|
-
#
|
10224
|
-
# == View a list of all your routes
|
10225
|
-
#
|
10226
|
-
# rails routes
|
10227
|
-
#
|
10228
|
-
# Target a specific controller with <tt>-c</tt>, or grep routes
|
10229
|
-
# using <tt>-g</tt>. Useful in conjunction with <tt>--expanded</tt>
|
10230
|
-
# which displays routes vertically.
|
10231
|
-
module Routing
|
10232
|
-
extend ActiveSupport::Autoload
|
10233
|
-
|
10234
|
-
SEPARATORS: ::Array[untyped]
|
10235
|
-
|
10236
|
-
HTTP_METHODS: ::Array[untyped]
|
10237
|
-
end
|
10238
|
-
end
|
10239
|
-
|
10240
10097
|
module ActionDispatch
|
10241
10098
|
module Routing
|
10242
10099
|
class Redirect < Endpoint
|
@@ -10278,6 +10135,9 @@ module ActionDispatch
|
|
10278
10135
|
end
|
10279
10136
|
|
10280
10137
|
class OptionRedirect < Redirect
|
10138
|
+
# :nodoc:
|
10139
|
+
alias options block
|
10140
|
+
|
10281
10141
|
def path: (untyped params, untyped request) -> untyped
|
10282
10142
|
|
10283
10143
|
def inspect: () -> ::String
|
@@ -10340,6 +10200,12 @@ module ActionDispatch
|
|
10340
10200
|
module Routing
|
10341
10201
|
# :stopdoc:
|
10342
10202
|
class RouteSet
|
10203
|
+
# Since the router holds references to many parts of the system
|
10204
|
+
# like engines, controllers and the application itself, inspecting
|
10205
|
+
# the route set can actually be really slow, therefore we default
|
10206
|
+
# alias inspect to to_s.
|
10207
|
+
alias inspect to_s
|
10208
|
+
|
10343
10209
|
class Dispatcher < Routing::Endpoint
|
10344
10210
|
def initialize: (untyped raise_on_name_error) -> untyped
|
10345
10211
|
|
@@ -10384,6 +10250,12 @@ module ActionDispatch
|
|
10384
10250
|
|
10385
10251
|
def key?: (untyped name) -> (nil | untyped)
|
10386
10252
|
|
10253
|
+
alias []= add
|
10254
|
+
|
10255
|
+
alias [] get
|
10256
|
+
|
10257
|
+
alias clear clear!
|
10258
|
+
|
10387
10259
|
def each: () { (untyped, untyped) -> untyped } -> untyped
|
10388
10260
|
|
10389
10261
|
def names: () -> untyped
|
@@ -10467,6 +10339,8 @@ module ActionDispatch
|
|
10467
10339
|
|
10468
10340
|
attr_reader polymorphic_mappings: untyped
|
10469
10341
|
|
10342
|
+
alias routes set
|
10343
|
+
|
10470
10344
|
def self.default_resources_path_names: () -> { new: "new", edit: "edit" }
|
10471
10345
|
|
10472
10346
|
def self.new_with_config: (untyped config) -> untyped
|
@@ -10629,6 +10503,8 @@ module ActionDispatch
|
|
10629
10503
|
|
10630
10504
|
attr_accessor routes: untyped
|
10631
10505
|
|
10506
|
+
alias _routes routes
|
10507
|
+
|
10632
10508
|
def initialize: (untyped routes, untyped scope, untyped helpers, ?untyped? script_namer) -> untyped
|
10633
10509
|
|
10634
10510
|
def url_options: () -> untyped
|
@@ -10826,6 +10702,259 @@ module ActionDispatch
|
|
10826
10702
|
end
|
10827
10703
|
end
|
10828
10704
|
|
10705
|
+
module ActionDispatch
|
10706
|
+
# The routing module provides URL rewriting in native Ruby. It's a way to
|
10707
|
+
# redirect incoming requests to controllers and actions. This replaces
|
10708
|
+
# mod_rewrite rules. Best of all, Rails' \Routing works with any web server.
|
10709
|
+
# Routes are defined in <tt>config/routes.rb</tt>.
|
10710
|
+
#
|
10711
|
+
# Think of creating routes as drawing a map for your requests. The map tells
|
10712
|
+
# them where to go based on some predefined pattern:
|
10713
|
+
#
|
10714
|
+
# Rails.application.routes.draw do
|
10715
|
+
# Pattern 1 tells some request to go to one place
|
10716
|
+
# Pattern 2 tell them to go to another
|
10717
|
+
# ...
|
10718
|
+
# end
|
10719
|
+
#
|
10720
|
+
# The following symbols are special:
|
10721
|
+
#
|
10722
|
+
# :controller maps to your controller name
|
10723
|
+
# :action maps to an action with your controllers
|
10724
|
+
#
|
10725
|
+
# Other names simply map to a parameter as in the case of <tt>:id</tt>.
|
10726
|
+
#
|
10727
|
+
# == Resources
|
10728
|
+
#
|
10729
|
+
# Resource routing allows you to quickly declare all of the common routes
|
10730
|
+
# for a given resourceful controller. Instead of declaring separate routes
|
10731
|
+
# for your +index+, +show+, +new+, +edit+, +create+, +update+ and +destroy+
|
10732
|
+
# actions, a resourceful route declares them in a single line of code:
|
10733
|
+
#
|
10734
|
+
# resources :photos
|
10735
|
+
#
|
10736
|
+
# Sometimes, you have a resource that clients always look up without
|
10737
|
+
# referencing an ID. A common example, /profile always shows the profile of
|
10738
|
+
# the currently logged in user. In this case, you can use a singular resource
|
10739
|
+
# to map /profile (rather than /profile/:id) to the show action.
|
10740
|
+
#
|
10741
|
+
# resource :profile
|
10742
|
+
#
|
10743
|
+
# It's common to have resources that are logically children of other
|
10744
|
+
# resources:
|
10745
|
+
#
|
10746
|
+
# resources :magazines do
|
10747
|
+
# resources :ads
|
10748
|
+
# end
|
10749
|
+
#
|
10750
|
+
# You may wish to organize groups of controllers under a namespace. Most
|
10751
|
+
# commonly, you might group a number of administrative controllers under
|
10752
|
+
# an +admin+ namespace. You would place these controllers under the
|
10753
|
+
# <tt>app/controllers/admin</tt> directory, and you can group them together
|
10754
|
+
# in your router:
|
10755
|
+
#
|
10756
|
+
# namespace "admin" do
|
10757
|
+
# resources :posts, :comments
|
10758
|
+
# end
|
10759
|
+
#
|
10760
|
+
# Alternatively, you can add prefixes to your path without using a separate
|
10761
|
+
# directory by using +scope+. +scope+ takes additional options which
|
10762
|
+
# apply to all enclosed routes.
|
10763
|
+
#
|
10764
|
+
# scope path: "/cpanel", as: 'admin' do
|
10765
|
+
# resources :posts, :comments
|
10766
|
+
# end
|
10767
|
+
#
|
10768
|
+
# For more, see <tt>Routing::Mapper::Resources#resources</tt>,
|
10769
|
+
# <tt>Routing::Mapper::Scoping#namespace</tt>, and
|
10770
|
+
# <tt>Routing::Mapper::Scoping#scope</tt>.
|
10771
|
+
#
|
10772
|
+
# == Non-resourceful routes
|
10773
|
+
#
|
10774
|
+
# For routes that don't fit the <tt>resources</tt> mold, you can use the HTTP helper
|
10775
|
+
# methods <tt>get</tt>, <tt>post</tt>, <tt>patch</tt>, <tt>put</tt> and <tt>delete</tt>.
|
10776
|
+
#
|
10777
|
+
# get 'post/:id', to: 'posts#show'
|
10778
|
+
# post 'post/:id', to: 'posts#create_comment'
|
10779
|
+
#
|
10780
|
+
# Now, if you POST to <tt>/posts/:id</tt>, it will route to the <tt>create_comment</tt> action. A GET on the same
|
10781
|
+
# URL will route to the <tt>show</tt> action.
|
10782
|
+
#
|
10783
|
+
# If your route needs to respond to more than one HTTP method (or all methods) then using the
|
10784
|
+
# <tt>:via</tt> option on <tt>match</tt> is preferable.
|
10785
|
+
#
|
10786
|
+
# match 'post/:id', to: 'posts#show', via: [:get, :post]
|
10787
|
+
#
|
10788
|
+
# == Named routes
|
10789
|
+
#
|
10790
|
+
# Routes can be named by passing an <tt>:as</tt> option,
|
10791
|
+
# allowing for easy reference within your source as +name_of_route_url+
|
10792
|
+
# for the full URL and +name_of_route_path+ for the URI path.
|
10793
|
+
#
|
10794
|
+
# Example:
|
10795
|
+
#
|
10796
|
+
# # In config/routes.rb
|
10797
|
+
# get '/login', to: 'accounts#login', as: 'login'
|
10798
|
+
#
|
10799
|
+
# # With render, redirect_to, tests, etc.
|
10800
|
+
# redirect_to login_url
|
10801
|
+
#
|
10802
|
+
# Arguments can be passed as well.
|
10803
|
+
#
|
10804
|
+
# redirect_to show_item_path(id: 25)
|
10805
|
+
#
|
10806
|
+
# Use <tt>root</tt> as a shorthand to name a route for the root path "/".
|
10807
|
+
#
|
10808
|
+
# # In config/routes.rb
|
10809
|
+
# root to: 'blogs#index'
|
10810
|
+
#
|
10811
|
+
# # would recognize http://www.example.com/ as
|
10812
|
+
# params = { controller: 'blogs', action: 'index' }
|
10813
|
+
#
|
10814
|
+
# # and provide these named routes
|
10815
|
+
# root_url # => 'http://www.example.com/'
|
10816
|
+
# root_path # => '/'
|
10817
|
+
#
|
10818
|
+
# Note: when using +controller+, the route is simply named after the
|
10819
|
+
# method you call on the block parameter rather than map.
|
10820
|
+
#
|
10821
|
+
# # In config/routes.rb
|
10822
|
+
# controller :blog do
|
10823
|
+
# get 'blog/show', to: :list
|
10824
|
+
# get 'blog/delete', to: :delete
|
10825
|
+
# get 'blog/edit', to: :edit
|
10826
|
+
# end
|
10827
|
+
#
|
10828
|
+
# # provides named routes for show, delete, and edit
|
10829
|
+
# link_to @article.title, blog_show_path(id: @article.id)
|
10830
|
+
#
|
10831
|
+
# == Pretty URLs
|
10832
|
+
#
|
10833
|
+
# Routes can generate pretty URLs. For example:
|
10834
|
+
#
|
10835
|
+
# get '/articles/:year/:month/:day', to: 'articles#find_by_id', constraints: {
|
10836
|
+
# year: /\d{4}/,
|
10837
|
+
# month: /\d{1,2}/,
|
10838
|
+
# day: /\d{1,2}/
|
10839
|
+
# }
|
10840
|
+
#
|
10841
|
+
# Using the route above, the URL "http://localhost:3000/articles/2005/11/06"
|
10842
|
+
# maps to
|
10843
|
+
#
|
10844
|
+
# params = {year: '2005', month: '11', day: '06'}
|
10845
|
+
#
|
10846
|
+
# == Regular Expressions and parameters
|
10847
|
+
# You can specify a regular expression to define a format for a parameter.
|
10848
|
+
#
|
10849
|
+
# controller 'geocode' do
|
10850
|
+
# get 'geocode/:postalcode', to: :show, constraints: {
|
10851
|
+
# postalcode: /\d{5}(-\d{4})?/
|
10852
|
+
# }
|
10853
|
+
# end
|
10854
|
+
#
|
10855
|
+
# Constraints can include the 'ignorecase' and 'extended syntax' regular
|
10856
|
+
# expression modifiers:
|
10857
|
+
#
|
10858
|
+
# controller 'geocode' do
|
10859
|
+
# get 'geocode/:postalcode', to: :show, constraints: {
|
10860
|
+
# postalcode: /hx\d\d\s\d[a-z]{2}/i
|
10861
|
+
# }
|
10862
|
+
# end
|
10863
|
+
#
|
10864
|
+
# controller 'geocode' do
|
10865
|
+
# get 'geocode/:postalcode', to: :show, constraints: {
|
10866
|
+
# postalcode: /# Postalcode format
|
10867
|
+
# \d{5} #Prefix
|
10868
|
+
# (-\d{4})? #Suffix
|
10869
|
+
# /x
|
10870
|
+
# }
|
10871
|
+
# end
|
10872
|
+
#
|
10873
|
+
# Using the multiline modifier will raise an +ArgumentError+.
|
10874
|
+
# Encoding regular expression modifiers are silently ignored. The
|
10875
|
+
# match will always use the default encoding or ASCII.
|
10876
|
+
#
|
10877
|
+
# == External redirects
|
10878
|
+
#
|
10879
|
+
# You can redirect any path to another path using the redirect helper in your router:
|
10880
|
+
#
|
10881
|
+
# get "/stories", to: redirect("/posts")
|
10882
|
+
#
|
10883
|
+
# == Unicode character routes
|
10884
|
+
#
|
10885
|
+
# You can specify unicode character routes in your router:
|
10886
|
+
#
|
10887
|
+
# get "(trim non-ascii characters)", to: "welcome#index"
|
10888
|
+
#
|
10889
|
+
# == Routing to Rack Applications
|
10890
|
+
#
|
10891
|
+
# Instead of a String, like <tt>posts#index</tt>, which corresponds to the
|
10892
|
+
# index action in the PostsController, you can specify any Rack application
|
10893
|
+
# as the endpoint for a matcher:
|
10894
|
+
#
|
10895
|
+
# get "/application.js", to: Sprockets
|
10896
|
+
#
|
10897
|
+
# == Reloading routes
|
10898
|
+
#
|
10899
|
+
# You can reload routes if you feel you must:
|
10900
|
+
#
|
10901
|
+
# Rails.application.reload_routes!
|
10902
|
+
#
|
10903
|
+
# This will clear all named routes and reload config/routes.rb if the file has been modified from
|
10904
|
+
# last load. To absolutely force reloading, use <tt>reload!</tt>.
|
10905
|
+
#
|
10906
|
+
# == Testing Routes
|
10907
|
+
#
|
10908
|
+
# The two main methods for testing your routes:
|
10909
|
+
#
|
10910
|
+
# === +assert_routing+
|
10911
|
+
#
|
10912
|
+
# def test_movie_route_properly_splits
|
10913
|
+
# opts = {controller: "plugin", action: "checkout", id: "2"}
|
10914
|
+
# assert_routing "plugin/checkout/2", opts
|
10915
|
+
# end
|
10916
|
+
#
|
10917
|
+
# +assert_routing+ lets you test whether or not the route properly resolves into options.
|
10918
|
+
#
|
10919
|
+
# === +assert_recognizes+
|
10920
|
+
#
|
10921
|
+
# def test_route_has_options
|
10922
|
+
# opts = {controller: "plugin", action: "show", id: "12"}
|
10923
|
+
# assert_recognizes opts, "/plugins/show/12"
|
10924
|
+
# end
|
10925
|
+
#
|
10926
|
+
# Note the subtle difference between the two: +assert_routing+ tests that
|
10927
|
+
# a URL fits options while +assert_recognizes+ tests that a URL
|
10928
|
+
# breaks into parameters properly.
|
10929
|
+
#
|
10930
|
+
# In tests you can simply pass the URL or named route to +get+ or +post+.
|
10931
|
+
#
|
10932
|
+
# def send_to_jail
|
10933
|
+
# get '/jail'
|
10934
|
+
# assert_response :success
|
10935
|
+
# end
|
10936
|
+
#
|
10937
|
+
# def goes_to_login
|
10938
|
+
# get login_url
|
10939
|
+
# #...
|
10940
|
+
# end
|
10941
|
+
#
|
10942
|
+
# == View a list of all your routes
|
10943
|
+
#
|
10944
|
+
# rails routes
|
10945
|
+
#
|
10946
|
+
# Target a specific controller with <tt>-c</tt>, or grep routes
|
10947
|
+
# using <tt>-g</tt>. Useful in conjunction with <tt>--expanded</tt>
|
10948
|
+
# which displays routes vertically.
|
10949
|
+
module Routing
|
10950
|
+
extend ActiveSupport::Autoload
|
10951
|
+
|
10952
|
+
SEPARATORS: ::Array[untyped]
|
10953
|
+
|
10954
|
+
HTTP_METHODS: ::Array[untyped]
|
10955
|
+
end
|
10956
|
+
end
|
10957
|
+
|
10829
10958
|
module ActionDispatch
|
10830
10959
|
# = System Testing
|
10831
10960
|
#
|
@@ -11128,20 +11257,6 @@ module ActionDispatch
|
|
11128
11257
|
end
|
11129
11258
|
end
|
11130
11259
|
|
11131
|
-
module ActionDispatch
|
11132
|
-
module Assertions
|
11133
|
-
extend ActiveSupport::Concern
|
11134
|
-
|
11135
|
-
include ResponseAssertions
|
11136
|
-
|
11137
|
-
include RoutingAssertions
|
11138
|
-
|
11139
|
-
include Rails::Dom::Testing::Assertions
|
11140
|
-
|
11141
|
-
def html_document: () -> untyped
|
11142
|
-
end
|
11143
|
-
end
|
11144
|
-
|
11145
11260
|
module ActionDispatch
|
11146
11261
|
module Assertions
|
11147
11262
|
# A small suite of assertions that test responses from \Rails applications.
|
@@ -11305,6 +11420,20 @@ module ActionDispatch
|
|
11305
11420
|
end
|
11306
11421
|
end
|
11307
11422
|
|
11423
|
+
module ActionDispatch
|
11424
|
+
module Assertions
|
11425
|
+
extend ActiveSupport::Concern
|
11426
|
+
|
11427
|
+
include ResponseAssertions
|
11428
|
+
|
11429
|
+
include RoutingAssertions
|
11430
|
+
|
11431
|
+
include Rails::Dom::Testing::Assertions
|
11432
|
+
|
11433
|
+
def html_document: () -> untyped
|
11434
|
+
end
|
11435
|
+
end
|
11436
|
+
|
11308
11437
|
module ActionDispatch
|
11309
11438
|
module Integration
|
11310
11439
|
# nodoc:
|
@@ -11448,6 +11577,11 @@ module ActionDispatch
|
|
11448
11577
|
# process :get, '/author', params: { since: 201501011400 }
|
11449
11578
|
def process: (untyped method, untyped path, ?params: untyped? params, ?headers: untyped? headers, ?env: untyped? env, ?xhr: bool xhr, ?as: untyped? as) -> untyped
|
11450
11579
|
|
11580
|
+
# Set the host name to use in the next request.
|
11581
|
+
#
|
11582
|
+
# session.host! "www.example.com"
|
11583
|
+
alias host! host=
|
11584
|
+
|
11451
11585
|
def _mock_session: () -> untyped
|
11452
11586
|
|
11453
11587
|
def build_full_uri: (untyped path, untyped env) -> ::String
|
@@ -11654,6 +11788,26 @@ module ActionDispatch
|
|
11654
11788
|
end
|
11655
11789
|
end
|
11656
11790
|
|
11791
|
+
module Rack
|
11792
|
+
end
|
11793
|
+
|
11794
|
+
module ActionDispatch
|
11795
|
+
extend ActiveSupport::Autoload
|
11796
|
+
|
11797
|
+
class IllegalStateError < StandardError
|
11798
|
+
end
|
11799
|
+
|
11800
|
+
class MissingController[T] < NameError[T]
|
11801
|
+
end
|
11802
|
+
|
11803
|
+
module Http
|
11804
|
+
extend ActiveSupport::Autoload
|
11805
|
+
end
|
11806
|
+
|
11807
|
+
module Session
|
11808
|
+
end
|
11809
|
+
end
|
11810
|
+
|
11657
11811
|
module ActionPack
|
11658
11812
|
# Returns the version of the currently loaded Action Pack as a <tt>Gem::Version</tt>
|
11659
11813
|
def self.gem_version: () -> Gem::Version
|