active_resource-dirty 1.0.2 → 1.0.3

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: d98172d32255ca5882b79100e2c6257a5b623b90ddc5b8ce9d57d97452165131
4
- data.tar.gz: 1bc9e10991ef5faf916fb111ca89872a0e78d093b079c52b066498d864fb24ab
3
+ metadata.gz: 0dc92b649c5aa69ff2a6a5db881987d77b10324dc950948859d3d393d8755a32
4
+ data.tar.gz: 70d402d1eb8fc49d6864e12c662fb5031a80109c55cc7bea562ef6e11d55492c
5
5
  SHA512:
6
- metadata.gz: 5e424dba23d1b95670ed7125057289b2e80d7ca55d2e211e47d7285b70659ee72bfd353381314ecfe9a756141349508f696987e346b6367879a1ea224a8388a9
7
- data.tar.gz: bbff8f80bbed256096531c637e322733dc89b124d2832dcd84d1b964d9e622a8e7f75ac35c330c54a3e6b121f6c0432d5ba42e829b4ea217ae15c6fcdbdd48aa
6
+ metadata.gz: 864df262f5b13f8f61f2d80be0f492087a0f909cfe8e2f75b972998d3895ad812a04c7741547d95917864b5860d78e47de41938f6c8d3685d50ac20d2ebf0893
7
+ data.tar.gz: a7003766fa557bdbfc3b01033b757202bb3087a521195464d28e9c92821394e94ca6de138968266a4b4fd712b9694cc9c5703470226e8c2c3a4d69628d155c19
@@ -17,6 +17,20 @@ module ActiveResource
17
17
  end
18
18
  end
19
19
 
20
+ def update_attributes(attributes)
21
+ unless attributes.respond_to?(:to_hash)
22
+ raise ArgumentError, 'expected attributes to be able to convert'\
23
+ " to Hash, got #{attributes.inspect}"
24
+ end
25
+
26
+ attributes = attributes.to_hash
27
+ attributes.each do |key, value|
28
+ send("#{key}=".to_sym, value)
29
+ end
30
+
31
+ save
32
+ end
33
+
20
34
  def respond_to_missing?(method_name, include_private = false)
21
35
  method_name.to_s.end_with?('=') || super
22
36
  end
@@ -53,11 +67,6 @@ module ActiveResource
53
67
  # Monkey patch
54
68
  def forget_attribute_assignments; end
55
69
 
56
- def encode_changed_attributes(options = {})
57
- format_options = options.merge(only: keys_for_partial_write)
58
- send("to_#{self.class.format.extension}", format_options)
59
- end
60
-
61
70
  def keys_for_partial_write
62
71
  changed_attributes.keys
63
72
  end
@@ -72,7 +81,7 @@ module ActiveResource
72
81
 
73
82
  run_callbacks :update do
74
83
  connection.patch(element_path(prefix_options),
75
- encode_changed_attributes,
84
+ encode(only: keys_for_partial_write),
76
85
  self.class.headers).tap do |response|
77
86
  load_attributes_from_response(response)
78
87
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveResource
2
2
  module Dirty
3
- VERSION = '1.0.2'
3
+ VERSION = '1.0.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_resource-dirty
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francisco Caiceo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-12 00:00:00.000000000 Z
11
+ date: 2019-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel