custom_fielder 0.7.9 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: acab5142405cd94aef787c2ad05636343ddd3a93
4
- data.tar.gz: 4f8fc1953b4a043c7611434dcf429115913764d1
3
+ metadata.gz: 4c547cb274a34d4c8cd3ea3eaf2973291178a976
4
+ data.tar.gz: 0730ecc83fef7696da69d2adc90dd7d11015fe17
5
5
  SHA512:
6
- metadata.gz: c00a29f26871479d96ff4fb9cf88f23db5a49705959e77198b703f8d6877cdd4b1bd170db35b70487039128ccb65f02609ff4736b1134e8262c8401275b266c3
7
- data.tar.gz: a46469420a255abbab916716041631628a5aeb23b5188e7a4a321897dc9386c554c363bb0be24e5e124403bba94169dba0db498c84319ca1e6451d6fd47de431
6
+ metadata.gz: 8fd40c8770d9d718ef861122023ff6b1297f972fbcd2a72246425e875e794457c42bc2de722a80d914ce723d13799a18be5ca220fb4cdff269043898005480f4
7
+ data.tar.gz: 90fb1cbcdc87ae1074bc6daaf765ee760283c041ad19b05c13c410d6884ae77a5646f2e8d69d317ba022479b3990cf46e665163a067373962a754ef29d970274
@@ -25,6 +25,57 @@ module CustomFielder
25
25
  def value; super; end
26
26
  alias_method :raw_value, :value
27
27
  def value; deserialize_value; end;
28
+
29
+ ##
30
+ # Allows for the creation of many values at one time
31
+ # this will return an array where the first element is
32
+ # a boolean whose value corresponds to whether or not there
33
+ # were any errors, the second value is the array of values
34
+ # that were created
35
+ #
36
+ # @param values [Array]
37
+ # @return [Array<Boolean,Array<Value>>]
38
+ #
39
+ def self.create_many(values)
40
+ errors, values = false, transaction { create!(values) }
41
+ values.each { |v| errors = true if v.errors.any? }
42
+
43
+ [errors, values]
44
+ end
45
+
46
+ ##
47
+ # Allows for updating many value records at one time
48
+ # this will return an array where the first element is
49
+ # a boolean whose value corresponds to whether or not there
50
+ # were any errors, the second value is the array of values
51
+ # that were updated
52
+ #
53
+ # @param values [Array]
54
+ # @return [Array<Boolean,Array<Value>>]
55
+ #
56
+ def self.update_many(values)
57
+ errors, values = false, transaction { update!(values) }
58
+ values.each { |v| errors = true if v.errors.any? }
59
+
60
+ [errors, values]
61
+ end
62
+
63
+ ##
64
+ # Allows for the deletion of many values at one time
65
+ # this will return an array where the first element is a
66
+ # boolean whose value corresponds to whether or not there
67
+ # were any errors, the second value is the array of values
68
+ # that were deleted
69
+ #
70
+ # @param ids [Array]
71
+ # @return [Array<Boolean,Array<Value>>]
72
+ #
73
+ def self.delete_many(ids)
74
+ errors, values = false, transaction { where(id: ids).destroy_all }
75
+ values.each { |v| errors = true if v.errors.any? }
76
+
77
+ [errors, values]
78
+ end
28
79
 
29
80
  private
30
81
 
@@ -1,3 +1,3 @@
1
1
  module CustomFielder
2
- VERSION = "0.7.9"
2
+ VERSION = "0.8.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: custom_fielder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.9
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Hurst
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-08 00:00:00.000000000 Z
11
+ date: 2016-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails