action_kit_api 0.2.2 → 0.2.3
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.
@@ -10,6 +10,9 @@ module ActionKitApi
|
|
10
10
|
|
11
11
|
def initialize(hash = {})
|
12
12
|
@required_attrs ||= []
|
13
|
+
@read_only_attrs ||= []
|
14
|
+
@read_only_attrs << :created_at
|
15
|
+
@read_only_attrs << :updated_at
|
13
16
|
|
14
17
|
self.update(hash)
|
15
18
|
end
|
@@ -19,11 +22,9 @@ module ActionKitApi
|
|
19
22
|
|
20
23
|
raise MissingRequiredAttributeException "Unable to save incomplete object" unless self.valid?
|
21
24
|
|
22
|
-
# TODO: Add blacklisting to the model to prevent read-only attributes from syncing
|
23
|
-
# this is a temporary fix.
|
24
25
|
attrs_hash = self.to_hash
|
25
26
|
attrs_hash.delete_if do |k, v|
|
26
|
-
k
|
27
|
+
@read_only_attrs.include?(k)
|
27
28
|
end
|
28
29
|
|
29
30
|
response = ActionKitApi.connection.call("#{class_name}.save_or_create", attrs_hash)
|
@@ -63,6 +64,7 @@ module ActionKitApi
|
|
63
64
|
self.instance_variables.each do |iv|
|
64
65
|
key = iv.delete("@").to_sym
|
65
66
|
next if key == :required_attrs
|
67
|
+
next if key == :read_only_attrs
|
66
68
|
user_hash[key] = self.instance_variable_get(iv)
|
67
69
|
end
|
68
70
|
|
data/lib/action_kit_api/user.rb
CHANGED