Class: Getto::Roda::Decode::Post

Inherits:
Object
  • Object
show all
Defined in:
lib/getto/roda/decode.rb

Instance Method Summary collapse

Constructor Details

#initialize(content_type, body) ⇒ Post

Returns a new instance of Post.



8
9
10
11
# File 'lib/getto/roda/decode.rb', line 8

def initialize(content_type, body)
  @content_type = content_type
  @body = body
end

Instance Method Details

#to_hObject



13
14
15
16
17
18
# File 'lib/getto/roda/decode.rb', line 13

def to_h
  return unless @content_type == "application/json"
  ::JSON.parse @body
rescue ::JSON::ParserError
  nil
end