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( = {}) @messages = [] instance_hash = .fetch(json_prefix, ) 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 [:exception] [:exception].each_pair do |k, v| << {k => v} end end end |