Module: FlowChat::NamedConfiguration::ClassMethods

Defined in:
lib/flow_chat/named_configuration.rb

Instance Method Summary collapse

Instance Method Details

#clear_all!Object



37
38
39
40
# File 'lib/flow_chat/named_configuration.rb', line 37

def clear_all!
  FlowChat.logger.debug { "#{name}: Clearing all registered configurations" }
  configurations.clear
end

#configuration_labelObject

The platform's name as it appears in the not-found message. Overridden where the constant name and the product name differ, as with WhatsApp.



44
45
46
# File 'lib/flow_chat/named_configuration.rb', line 44

def configuration_label
  name.split("::")[-2]
end

#configuration_namesObject



33
34
35
# File 'lib/flow_chat/named_configuration.rb', line 33

def configuration_names
  configurations.keys
end

#exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/flow_chat/named_configuration.rb', line 29

def exists?(name)
  configurations.key?(name.to_sym)
end

#get(name) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/flow_chat/named_configuration.rb', line 18

def get(name)
  config = configurations[name.to_sym]
  unless config
    FlowChat.logger.error { "#{self.name}: Configuration '#{name}' not found" }
    raise ArgumentError, "#{configuration_label} configuration '#{name}' not found"
  end

  FlowChat.logger.debug { "#{self.name}: Retrieved configuration '#{name}'" }
  config
end

#register(name, config) ⇒ Object



13
14
15
16
# File 'lib/flow_chat/named_configuration.rb', line 13

def register(name, config)
  FlowChat.logger.debug { "#{self.name}: Registering configuration '#{name}'" }
  configurations[name.to_sym] = config
end