We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 547dda1 commit 317ca72Copy full SHA for 317ca72
lib/esdb/resource.rb
@@ -40,6 +40,19 @@ def get!(*args)
40
@response = get(*args)
41
end
42
43
+ # A kind of find_or_create - experimental.
44
+ # For example identities should be created and returned if sufficient
45
+ # identifying data is submitted, but no identity is found.
46
+ # A little HAX'ish right now, need to decide on naming/exact functionality
47
+ def self.sync(attrs = {})
48
+ # TODO: I miss reverse_merge!
49
+ attrs[:access_token] = ESDB.api_key if ESDB.api_key
50
+
51
+ resource = self.new(nil, {headers: {params: {id: 'find', create: true}.merge(attrs)}})
52
+ resource.get!
53
+ resource
54
+ end
55
56
def self.from_hash(hash)
57
resource = self.new
58
resource.response = hash
0 commit comments