module Hatena::Bookmark::Restful::V1::ResponseObject::ClassMethods

Public Instance Methods

new_from_response(res) click to toggle source

Create a new instance from JSON from the API

# File lib/hatena/bookmark/restful/v1/response_object.rb, line 12
def new_from_response(res)
  properties = self.const_get(:PROPERTIES)
  names      = properties.map(&:to_s)
  values     = res.values_at(*names)
  attrs      = Hash[ properties.zip(values) ]
  new(attrs)
end