Skip to content

Commit 99e456e

Browse files
committed
fix up Resource.from_hash, added Resource.from_json
1 parent 3ea9392 commit 99e456e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/esdb/resource.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,18 @@ def self.sync(attrs = {})
5353
resource
5454
end
5555

56+
def self.from_json(json)
57+
resource = self.new
58+
resource.instance_variable_set('@response', json)
59+
resource
60+
end
61+
5662
def self.from_hash(hash)
5763
resource = self.new
58-
resource.response = hash
64+
65+
# TODO: the response= setter is freaky, and I want to get rid of
66+
# RestClient anyway.
67+
resource.instance_variable_set('@response', hash.to_json)
5968
resource
6069
end
6170

0 commit comments

Comments
 (0)