action_kit_api 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 == :subscription_status
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
 
@@ -15,6 +15,7 @@ module ActionKitApi
15
15
 
16
16
  def initialize(*args)
17
17
  @required_attrs = [:email, :first_name, :last_name, :zip]
18
+ @read_only_attrs =[:subscription_status]
18
19
  super
19
20
  end
20
21
 
@@ -1,3 +1,3 @@
1
1
  module ActionKitApi
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 2
9
- version: 0.2.2
8
+ - 3
9
+ version: 0.2.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sam Stelfox