Class: Tokenable::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/tokenable/config.rb

Class Method Summary collapse

Class Method Details

.method_missing(method_name, *args, &block) ⇒ Object

We do this, as some of our defaults need to live in a Proc (as this library is loaded before Rails) This means we can return the value when the method is called, instead of the Proc.



20
21
22
# File 'lib/tokenable/config.rb', line 20

def self.method_missing(method_name, *args, &block)
  class_variable_defined?("@@#{method_name}") ? proc_reader(method_name) : super
end

.proc_reader(key) ⇒ Object



28
29
30
31
# File 'lib/tokenable/config.rb', line 28

def self.proc_reader(key)
  value = class_variable_get("@@#{key}")
  value.is_a?(Proc) ? value.call : value
end

.respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/tokenable/config.rb', line 24

def self.respond_to_missing?(method_name, include_private = false)
  class_variable_defined?("@@#{method_name}") || super
end