mirror of
https://github.com/samsonjs/instapaper.git
synced 2026-03-25 08:55:49 +00:00
update attribute types for bookmark model
the `hash` attribute has been renamed to `instapaper_hash` as the use of `hash` collides with equalizer's implementation and results in a StackLevelError
This commit is contained in:
parent
26288c458b
commit
770a722c09
2 changed files with 17 additions and 10 deletions
|
|
@ -5,17 +5,17 @@ module Instapaper
|
|||
include Virtus.value_object
|
||||
|
||||
values do
|
||||
attribute :type, String
|
||||
attribute :bookmark_id, String
|
||||
attribute :url, String
|
||||
attribute :title, String
|
||||
attribute :instapaper_hash, String
|
||||
attribute :description, String
|
||||
attribute :time, String
|
||||
attribute :starred, String
|
||||
attribute :bookmark_id, Integer
|
||||
attribute :private_source, String
|
||||
attribute :hash, String
|
||||
attribute :title, String
|
||||
attribute :url, String
|
||||
attribute :progress_timestamp, DateTime
|
||||
attribute :time, DateTime
|
||||
attribute :progress, String
|
||||
attribute :progress_timestamp, String
|
||||
attribute :starred, String
|
||||
attribute :type, String
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ module Instapaper
|
|||
# @param klass [Class]
|
||||
def perform_request_with_objects(request_method, path, options, klass)
|
||||
perform_request(request_method, path, options).collect do |element|
|
||||
klass.new(element)
|
||||
klass.new(coerce_hash(element))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ module Instapaper
|
|||
def perform_request_with_object(request_method, path, options, klass)
|
||||
response = perform_request(request_method, path, options)
|
||||
response = response.is_a?(Array) ? response.first : response
|
||||
klass.new(response)
|
||||
klass.new(coerce_hash(response))
|
||||
end
|
||||
|
||||
# @param path [String]
|
||||
|
|
@ -48,6 +48,13 @@ module Instapaper
|
|||
def perform_request(method, path, options)
|
||||
Instapaper::HTTP::Request.new(self, method, path, options).perform
|
||||
end
|
||||
|
||||
def coerce_hash(response)
|
||||
if response.key?('hash')
|
||||
response['instapaper_hash'] = response.delete('hash')
|
||||
end
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue