Module: AwsIotDevice::MqttAdapter

Extended by:
MqttAdapter
Included in:
MqttAdapter
Defined in:
lib/aws_iot_device/mqtt_adapter.rb,
lib/aws_iot_device/mqtt_adapter/client.rb,
lib/aws_iot_device/mqtt_adapter/paho_mqtt_adapter.rb,
lib/aws_iot_device/mqtt_adapter/ruby_mqtt_adapter.rb

Defined Under Namespace

Classes: Client, PahoMqttAdapter, RubyMqttAdapter

Instance Method Summary collapse

Instance Method Details

#adapterObject

Return the adapter selected for the module with either a pre-setted value or a default value



9
10
11
12
13
14
# File 'lib/aws_iot_device/mqtt_adapter.rb', line 9

def adapter
  return @adapter if @adapter
  ### Calling the setter method with the default symbol 'RubyMqttAdapter' and return it.
  self.adapter = :paho_mqtt_adapter
  @adapter
end

#adapter=(adapter_lib) ⇒ Object

The setter of the module’s adapter attributes



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/aws_iot_device/mqtt_adapter.rb', line 17

def adapter=(adapter_lib)
  case adapter_lib
  when Symbol, String
    begin
      require "aws_iot_device/mqtt_adapter/#{adapter_lib}"
    rescue LoadError
      raise "LoadError: Could find adapters for the lib #{adapter_lib}"
    end
    @adapter = MqttAdapter.const_get("#{adapter_lib.to_s.camelcase(:upper)}")
  else
    raise "TypeError: Library name should be a String or Symbol"
  end
end