Class: BotMob::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/bot_mob/environment.rb

Overview

## BotMob::Environment

Provide convenience methods for tracking current BotMob runtime environment. Set using the environment variable: ‘ENV`

Instance Method Summary collapse

Constructor Details

#initialize(env = nil) ⇒ Environment

Returns a new instance of Environment.



8
9
10
# File 'lib/bot_mob/environment.rb', line 8

def initialize(env = nil)
  @env = env || 'development'
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



20
21
22
23
# File 'lib/bot_mob/environment.rb', line 20

def method_missing(method_name, *args)
  environment = method_name.to_s[/(.*)\?$/, 1]
  environment ? @env == environment : super
end

Instance Method Details

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

Returns:

  • (Boolean)


16
17
18
# File 'lib/bot_mob/environment.rb', line 16

def respond_to_missing?(method_name, include_private = false)
  method_name.to_s[/(.*)\?$/, 1] || super
end

#to_sObject



12
13
14
# File 'lib/bot_mob/environment.rb', line 12

def to_s
  @env
end