lockstep_rails 0.3.63 → 0.3.64

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c66de5c8265c8bf92d2d07b205a0a9de6340f00105ce5e6110cbc5002e73f0c
4
- data.tar.gz: 7a190529d4a770714f9708aa3305c3eda6c23f92a1f80ce71eb6186f8cc2e6c6
3
+ metadata.gz: d83e57b6db6e9db14cd4f15009562ccd5d0d04efa90a70b06f5f60a58ac53f40
4
+ data.tar.gz: c4830314919f4710198deb5e2931808ed9b6533d727eb992ba4d1532473ff427
5
5
  SHA512:
6
- metadata.gz: 84608aaf9a7aebf1946f49b9e85dcced53535ad6832f0c0d3f610f255bdf6a016110dff2b78107b6b18d99734b8c968ce4ddc58b89e39ffa7312d4718100e142
7
- data.tar.gz: 9553d0c197a324d3bf7980b518d42264cc4e9533867ee1847b60148612e315965401b637896c3751422ca7b9db358dccd31404646822b4a87608768b1175ba94
6
+ metadata.gz: 70ce01db3c9b2e45047839ab02ca21dc01f82a781c0b2489dc320931b3774c4d8c720aa2665cc142738dd6892ea92f53f708233fee0758f1a29fa14eab20a89c
7
+ data.tar.gz: 58b0d4ed3f52e6c72a1bd3d52f9b3eaf10b8cf5853e03720d9927f33fb4af2eb8e10362821cf43ea621d0d151bcf314a5975580de01b5526552e2169e506e68c
data/README.md CHANGED
@@ -166,6 +166,14 @@ if you wish, you can always write raw [Searchlight](https://developer.lockstep.i
166
166
  Lockstep::Connection.where("isActive is true OR default_currency_code in ('USD', 'INR')").execute
167
167
  ```
168
168
 
169
+ ### Destroy and Destroy all
170
+ You can destroy a single object by calling destroy method on one object
171
+ Lockstep::Connection.find(company_id: "17544da8-7be8-4ee2-8c62-cbd81428c68b").destroy
172
+
173
+ You can also destroy multiple objects at once by calling it on the model class and passing an array of relevant ids
174
+
175
+ Lockstep::Connection.destroy_all(id: ["17544da8-7be8-4ee2-8c62-cbd81428c68b"])
176
+
169
177
  ### Count
170
178
  You can fetch the count of available records by calling `count`
171
179
 
@@ -572,13 +572,6 @@ module Lockstep
572
572
  obj
573
573
  end
574
574
 
575
- # Replaced with a batch destroy_all method.
576
- # def self.destroy_all(all)
577
- # all.each do |object|
578
- # object.destroy
579
- # end
580
- # end
581
-
582
575
  def self.class_attributes
583
576
  @class_attributes ||= {}
584
577
  end
@@ -822,6 +815,18 @@ module Lockstep
822
815
  false
823
816
  end
824
817
 
818
+ def self.destroy_all(id: [])
819
+ id.each_slice(100) do |sliced_ids|
820
+ resp = resource.delete('', body: { 'idsToDelete' => sliced_ids })
821
+ return false unless resp.code.to_s == '200'
822
+ # TODO: Since this could fail for certain IDs return deleted_ids in batch
823
+ end
824
+
825
+ @attributes = {}
826
+ @unsaved_attributes = {}
827
+ return true
828
+ end
829
+
825
830
  def reload
826
831
  return false if new?
827
832
 
@@ -159,8 +159,8 @@ module Lockstep
159
159
  request(:put, path, body, params)
160
160
  end
161
161
 
162
- def delete(path)
163
- request(:delete, path, {}, {})
162
+ def delete(path, body: {})
163
+ request(:delete, path, body, {})
164
164
  end
165
165
 
166
166
  def post_magic_link(path, body: {}, params: {})
@@ -1,3 +1,3 @@
1
1
  module LockstepRails
2
- VERSION = '0.3.63'
2
+ VERSION = '0.3.64'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lockstep_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.63
4
+ version: 0.3.64
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vivek AG
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-01 00:00:00.000000000 Z
11
+ date: 2023-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails