Module: Hatena::Bookmark::Restful::V1::ResponseObject::ClassMethods
- Defined in:
- lib/hatena/bookmark/restful/v1/response_object.rb
Instance Method Summary collapse
-
#new_from_response(res) ⇒ Object
Create a new instance from JSON from the API.
Instance Method Details
#new_from_response(res) ⇒ Object
Create a new instance from JSON from the API
12 13 14 15 16 17 18 |
# 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 |