class MessageBird::Base
Public Class Methods
new(json)
click to toggle source
# File lib/messagebird/base.rb, line 17 def initialize(json) map_hash_elements_to_self(json) end
Public Instance Methods
map_hash_elements_to_self(hash)
click to toggle source
takes each element from the given hash and apply it to ourselves through an assignment method
# File lib/messagebird/base.rb, line 9 def map_hash_elements_to_self(hash) hash.each do |key, value| method_name = key.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase # convert came case to snake case method_name += '=' send(method_name, value) if respond_to?(method_name) end end
value_to_time(value)
click to toggle source
# File lib/messagebird/base.rb, line 21 def value_to_time(value) value ? Time.parse(value) : nil end