Module: OmniAuth::Strategy::ClassMethods
- Defined in:
- lib/omniauth/strategy.rb
Instance Method Summary collapse
-
#args(args = nil) ⇒ Object
Sets (and retrieves) option key names for initializer arguments to be recorded as.
- #compile_stack(ancestors, method, context) ⇒ Object
-
#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.
-
#default_options ⇒ Object
Returns an inherited set of default options set at the class-level for each strategy.
-
#option(name, value = nil) ⇒ Object
Directly declare a default option for your class.
Instance Method Details
#args(args = nil) ⇒ Object
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.
81 82 83 84 85 |
# File 'lib/omniauth/strategy.rb', line 81 def args(args = nil) @args = Array(args) and return if args existing = superclass.respond_to?(:args) ? superclass.args : [] return @args || existing end |
#compile_stack(ancestors, method, context) ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/omniauth/strategy.rb', line 100 def compile_stack(ancestors, method, context) stack = ancestors.inject([]) do |a, ancestor| a << context.instance_eval(&ancestor.send(method)) if ancestor.respond_to?(method) && ancestor.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.
54 55 56 57 |
# File 'lib/omniauth/strategy.rb', line 54 def configure( = nil) yield and return unless .deep_merge!() end |
#default_options ⇒ Object
Returns an inherited set of default options set at the class-level for each strategy.
26 27 28 29 30 |
# File 'lib/omniauth/strategy.rb', line 26 def return @default_options if @default_options existing = superclass.respond_to?(:default_options) ? superclass. : {} @default_options = OmniAuth::Strategy::Options.new(existing) end |
#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.
74 75 76 |
# File 'lib/omniauth/strategy.rb', line 74 def option(name, value = nil) [name] = value end |