Module: OmniAuth::Strategy::ClassMethods
- Included in:
- OmniAuth::Strategies::Developer
- Defined in:
- lib/omniauth/strategy/class_methods.rb,
sig/omniauth.rbs
Constant Summary collapse
- DISPATCH_METHODS =
%i[call! phase_call options_call? request_call? on_auth_path?].freeze
Instance Method Summary collapse
-
#allocate ⇒ Strategy
Defined by Class.
-
#ancestors ⇒ Array[Module]
Defined by Module, which every strategy class is.
-
#args(args = nil) ⇒ Object
Sets (and retrieves) option key names for initializer arguments to be recorded as.
- #class_eval ⇒ Object
- #compile_stack(ancestors, method, context) ⇒ Array[untyped]
-
#configure(options = nil) {|Options| ... } ⇒ Object
This allows for more declarative subclassing of strategies by allowing default options to be set using a simple configure call.
- #credentials { ... } ⇒ Object
- #credentials_stack ⇒ Array[Hash[untyped, untyped]]
-
#default_dispatch? ⇒ Boolean
private
True when requests are dispatched by OmniAuth's own #call! and its phase checks, so #call can tell which ones would go to the app.
-
#default_options ⇒ Options
Returns an inherited set of default options set at the class-level for each strategy.
- #extra { ... } ⇒ Object
- #extra_stack ⇒ Array[Hash[untyped, untyped]]
- #info { ... } ⇒ Object
- #info_stack ⇒ Array[Hash[untyped, untyped]]
- #instance_method ⇒ UnboundMethod
- #name ⇒ String?
-
#option(name, value = nil) ⇒ Object
Directly declare a default option for your class.
- #superclass ⇒ Class?
-
#uid { ... } ⇒ Object
The fetcher blocks run with the strategy instance as self.
- #uid_stack ⇒ Array[untyped]
Instance Method Details
#allocate ⇒ Strategy
Defined by Class.
355 |
# File 'sig/omniauth.rbs', line 355
def allocate: () -> Strategy
|
#ancestors ⇒ Array[Module]
Defined by Module, which every strategy class is.
348 |
# File 'sig/omniauth.rbs', line 348
def ancestors: () -> Array[Module]
|
#args ⇒ Array[Symbol] #args(args) ⇒ nil
Sets (and retrieves) option key names for initializer arguments to be recorded as. This takes care of 90% of the use cases for overriding the initializer in OmniAuth Strategies.
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/omniauth/strategy/class_methods.rb', line 80 def args(args = nil) if args @args = args.is_a?(Array) ? args : [args] return end return @args if instance_variable_defined?(:@args) parent = superclass parent.is_a?(ClassMethods) ? parent.args : [] end |
#class_eval ⇒ Object
351 |
# File 'sig/omniauth.rbs', line 351
def class_eval: (String code, ?String file, ?Integer line) -> untyped
|
#compile_stack(ancestors, method, context) ⇒ Array[untyped]
107 108 109 110 111 112 113 114 115 |
# File 'lib/omniauth/strategy/class_methods.rb', line 107 def compile_stack(ancestors, method, context) stack = ancestors.inject([]) do |a, ancestor| # Only strategy classes define these blocks. Other ancestors may # respond to the same names (e.g. a monkeypatched Object#info). a << context.instance_eval(&ancestor.public_send(method)) if ancestor.is_a?(ClassMethods) && ancestor.public_send(method) a end stack.reverse end |
#configure(options = nil) {|Options| ... } ⇒ Object
This allows for more declarative subclassing of strategies by allowing default options to be set using a simple configure call.
50 51 52 53 54 55 56 |
# File 'lib/omniauth/strategy/class_methods.rb', line 50 def configure( = nil) if block_given? yield else .deep_merge!( || {}) end end |
#credentials ⇒ Proc #credentials ⇒ Proc?
337 338 |
# File 'sig/omniauth.rbs', line 337
def credentials: () { () [self: Strategy] -> Hash[untyped, untyped]? } -> Proc
| () -> Proc?
|
#credentials_stack ⇒ Array[Hash[untyped, untyped]]
343 |
# File 'sig/omniauth.rbs', line 343
def credentials_stack: (untyped context) -> Array[Hash[untyped, untyped]]
|
#default_dispatch? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
True when requests are dispatched by OmniAuth's own #call! and its phase checks, so #call can tell which ones would go to the app. They may live in Strategy or in a module it includes, like Paths. Methods patched directly onto Strategy count as its own.
13 14 15 16 17 |
# File 'lib/omniauth/strategy/class_methods.rb', line 13 def default_dispatch? return @default_dispatch if instance_variable_defined?(:@default_dispatch) @default_dispatch = DISPATCH_METHODS.all? { |m| Strategy.ancestors.include?(instance_method(m).owner) } end |
#default_options ⇒ Options
Returns an inherited set of default options set at the class-level for each strategy.
21 22 23 24 25 26 |
# File 'lib/omniauth/strategy/class_methods.rb', line 21 def @default_options ||= begin parent = superclass Options.new((parent. if parent.is_a?(ClassMethods))) end end |
#extra ⇒ Proc #extra ⇒ Proc?
334 335 |
# File 'sig/omniauth.rbs', line 334
def extra: () { () [self: Strategy] -> Hash[untyped, untyped]? } -> Proc
| () -> Proc?
|
#extra_stack ⇒ Array[Hash[untyped, untyped]]
342 |
# File 'sig/omniauth.rbs', line 342
def extra_stack: (untyped context) -> Array[Hash[untyped, untyped]]
|
#info ⇒ Proc #info ⇒ Proc?
331 332 |
# File 'sig/omniauth.rbs', line 331
def info: () { () [self: Strategy] -> Hash[untyped, untyped]? } -> Proc
| () -> Proc?
|
#info_stack ⇒ Array[Hash[untyped, untyped]]
341 |
# File 'sig/omniauth.rbs', line 341
def info_stack: (untyped context) -> Array[Hash[untyped, untyped]]
|
#instance_method ⇒ UnboundMethod
352 |
# File 'sig/omniauth.rbs', line 352
def instance_method: (Symbol name) -> UnboundMethod
|
#name ⇒ String?
350 |
# File 'sig/omniauth.rbs', line 350
def name: () -> String?
|
#option(name, value = nil) ⇒ Object
Directly declare a default option for your class. This is a useful from a documentation perspective as it provides a simple line-by-line analysis of the kinds of options your strategy provides by default.
73 74 75 |
# File 'lib/omniauth/strategy/class_methods.rb', line 73 def option(name, value = nil) [name] = value end |
#superclass ⇒ Class?
349 |
# File 'sig/omniauth.rbs', line 349
def superclass: () -> Class?
|
#uid ⇒ Proc #uid ⇒ Proc?
The fetcher blocks run with the strategy instance as self.
328 329 |
# File 'sig/omniauth.rbs', line 328
def uid: () { () [self: Strategy] -> untyped } -> Proc
| () -> Proc?
|
#uid_stack ⇒ Array[untyped]
340 |
# File 'sig/omniauth.rbs', line 340
def uid_stack: (untyped context) -> Array[untyped]
|