Class: Karafka::Env
- Inherits:
 - 
      String
      
        
- Object
 - String
 - Karafka::Env
 
 
- Defined in:
 - lib/karafka/env.rb
 
Overview
Env management class to get and set environment for Karafka
Instance Method Summary collapse
- 
  
    
      #initialize  ⇒ Karafka::Env 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
Env object.
 - 
  
    
      #method_missing(method_name, *arguments)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Reacts to missing methods, from which some might be the env checks.
 - 
  
    
      #respond_to_missing?(method_name, include_private = false)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
True if we respond to a given missing method, otherwise false.
 
Constructor Details
#initialize ⇒ Karafka::Env
    Note:
    
  
Will load appropriate environment automatically
Returns env object.
      20 21 22 23 24 25 26 27 28 29  | 
    
      # File 'lib/karafka/env.rb', line 20 def initialize super('') LOOKUP_ENV_KEYS .map { |key| ENV[key] } .compact .first .then { |env| env || DEFAULT_ENV } .then { |env| replace(env) } end  | 
  
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments) ⇒ Object
Reacts to missing methods, from which some might be the env checks. If the method ends with ‘?’ we assume, that it is an env check
      42 43 44  | 
    
      # File 'lib/karafka/env.rb', line 42 def method_missing(method_name, *arguments) method_name[-1] == '?' ? self == method_name[0..-2] : super end  | 
  
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Returns true if we respond to a given missing method, otherwise false.
      34 35 36  | 
    
      # File 'lib/karafka/env.rb', line 34 def respond_to_missing?(method_name, include_private = false) (method_name[-1] == '?') || super end  |