Module: Helpers::Accessor
- Included in:
- LimeLightPlatform
- Defined in:
- lib/lime_light_platform/helpers/accessor.rb
Instance Method Summary collapse
- #get_by_key(key, hash) ⇒ Object
- #get_if_exists(key, hash, default = '') ⇒ Object
- #get_response_code(hash = {}) ⇒ Object
- #key_exists(key, hash) ⇒ Object
- #map_param_if_exist(param_map, request, body = {}) ⇒ Object
Instance Method Details
#get_by_key(key, hash) ⇒ Object
17 18 19 |
# File 'lib/lime_light_platform/helpers/accessor.rb', line 17 def get_by_key key, hash hash[key] end |
#get_if_exists(key, hash, default = '') ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/lime_light_platform/helpers/accessor.rb', line 3 def get_if_exists key, hash, default='' value = default if !hash[key].nil? value = hash[key] end value end |
#get_response_code(hash = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/lime_light_platform/helpers/accessor.rb', line 33 def get_response_code hash={} response_code = '' if key_exists 'response_code', hash response_code = hash['response_code'] elsif key_exists 'responseCode', hash response_code = hash['responseCode'] elsif key_exists 'response', hash response_code = hash['response'] end response_code end |
#key_exists(key, hash) ⇒ Object
13 14 15 |
# File 'lib/lime_light_platform/helpers/accessor.rb', line 13 def key_exists key, hash !hash[key].nil? end |
#map_param_if_exist(param_map, request, body = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/lime_light_platform/helpers/accessor.rb', line 21 def map_param_if_exist param_map, request, body={} param_map.each do |key, mapped_key| str_mapped_key = key.to_s if key_exists(str_mapped_key, request) body[mapped_key] = request[str_mapped_key] end end body end |