Module: Postmark::Inbound

Extended by:
Inbound
Included in:
Inbound
Defined in:
lib/postmark/inbound.rb

Instance Method Summary collapse

Instance Method Details

#to_ruby_hash(inbound) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/postmark/inbound.rb', line 5

def to_ruby_hash(inbound)
  inbound = Json.decode(inbound) if inbound.is_a?(String)
  ret = HashHelper.to_ruby(inbound)
  ret[:from_full] ||= {}
  ret[:to_full] ||= []
  ret[:cc_full] ||= []
  ret[:headers] ||= []
  ret[:attachments] ||= []
  ret[:from_full] = HashHelper.to_ruby(ret[:from_full])
  ret[:to_full] = ret[:to_full].map { |to| HashHelper.to_ruby(to) }
  ret[:cc_full] = ret[:cc_full].map { |cc| HashHelper.to_ruby(cc) }
  ret[:headers] = ret[:headers].map { |h| HashHelper.to_ruby(h) }
  ret[:attachments] = ret[:attachments].map { |a| HashHelper.to_ruby(a) }
  ret
end