Method: BasecommSdk::Base#initialize

Defined in:
lib/basecomm_sdk/base.rb

#initialize(options = {}) ⇒ Base

Accepts prefixed attribute keys as well as non-prefixed



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/basecomm_sdk/base.rb', line 15

def initialize(options = {})
  @messages = []
  instance_hash = options.fetch(json_prefix, options)
  attributes.each do |atr|
    instance_variable_set(
      "@#{atr}",
      instance_hash.fetch(
        "#{json_prefix}_#{atr}".to_sym,
        instance_hash.fetch(
          "#{atr}".to_sym,
          nil
        )
      )
    )
  end
  # Populate messages with exceptions
  if options[:exception]
    options[:exception].each_pair do |k, v|
      messages << {k => v}
    end
  end
end