Module: DeviceCloud::Configuration

Included in:
DeviceCloud
Defined in:
lib/device_cloud/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#alert_notification_handlerObject

Proc that will be called for handling DeviceCloud::PushNotification::AlertNotification objects Proc will be called with the alert notification object



32
33
34
# File 'lib/device_cloud/configuration.rb', line 32

def alert_notification_handler
  @alert_notification_handler
end

#data_notification_handlerObject

Proc that will be called for handling DeviceCloud::PushNotification::DataNotification objects Proc will be called with the data notification object



43
44
45
# File 'lib/device_cloud/configuration.rb', line 43

def data_notification_handler
  @data_notification_handler
end

#empty_alert_notification_handlerObject

Proc that will be called for handling DeviceCloud::PushNotification::AlertNotification objects that do not contain file data (data too large - over 120KB) Proc will be called with the alert notification object



38
39
40
# File 'lib/device_cloud/configuration.rb', line 38

def empty_alert_notification_handler
  @empty_alert_notification_handler
end

#empty_data_notification_handlerObject

Proc that will be called for handling DeviceCloud::PushNotification::DataNotification objects that do not contain file data (data too large - over 120KB) Proc will be called with the data notification object



49
50
51
# File 'lib/device_cloud/configuration.rb', line 49

def empty_data_notification_handler
  @empty_data_notification_handler
end

#empty_event_notification_handlerObject

Proc that will be called for handling DeviceCloud::PushNotification::EventNotification objects that do not contain file data (data too large - over 120KB) Proc will be called with the event notification object



27
28
29
# File 'lib/device_cloud/configuration.rb', line 27

def empty_event_notification_handler
  @empty_event_notification_handler
end

#event_notification_handlerObject

Proc that will be called for handling DeviceCloud::PushNotification::EventNotification objects Proc will be called with the event notification object



21
22
23
# File 'lib/device_cloud/configuration.rb', line 21

def event_notification_handler
  @event_notification_handler
end

#loggerObject

DeviceCloud logger

Returns:

  • the DeviceCloud logger or set the default to stdout



104
105
106
# File 'lib/device_cloud/configuration.rb', line 104

def logger
  @logger ||= Logger.new(STDOUT)
end

#passwordObject

DeviceCloud password

Returns:

  • the DeviceCloud password or raises an error



96
97
98
99
# File 'lib/device_cloud/configuration.rb', line 96

def password
  raise 'DeviceCloud password is blank' if @password.blank?
  @password
end

#root_urlObject

DeviceCloud url

Returns:

  • the DeviceCloud url or the default of ‘my.idigi.com’ if not set.



81
82
83
# File 'lib/device_cloud/configuration.rb', line 81

def root_url
  @root_url ||= 'https://my.idigi.com'
end

#usernameObject

DeviceCloud username

Returns:

  • the DeviceCloud username or raises an error



88
89
90
91
# File 'lib/device_cloud/configuration.rb', line 88

def username
  raise 'DeviceCloud username is blank' if @username.blank?
  @username
end

Instance Method Details

#configObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/device_cloud/configuration.rb', line 63

def config
  {
    username: username,
    password: password,
    root_url: root_url,
    alert_notification_handler: @alert_notification_handler,
    empty_alert_notification_handler: @empty_alert_notification_handler,
    data_notification_handler: @data_notification_handler,
    empty_data_notification_handler: @empty_data_notification_handler,
    event_notification_handler: @event_notification_handler,
    empty_event_notification_handler: @empty_event_notification_handler,
    logger: logger
  }.freeze
end

#configure {|_self| ... } ⇒ Object

Yield self to be able to configure ActivityFeed with block-style configuration.

Example:

ActivityFeed.configure do |configuration|
  configuration.root_url = 'https://example.com'
end

Yields:

  • (_self)

Yield Parameters:



59
60
61
# File 'lib/device_cloud/configuration.rb', line 59

def configure
  yield self
end