nylas 4.2.1 → 4.2.2

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
  SHA1:
3
- metadata.gz: b4d46688295bf8c7e3c07d743c30b4450823fe0e
4
- data.tar.gz: 7d3cf939484ace373e1cc4678c9568095d473a04
3
+ metadata.gz: 96b809ac0220aafde8e93c2c96cabb0a183c11ca
4
+ data.tar.gz: 818166a918cf4e43d193e606c2449cebd051aa78
5
5
  SHA512:
6
- metadata.gz: 928b321e8608c1e682282e889810cddec1061e5dde76851dd149d73cdf42d883e06ac4fae259f277f970c3500d400cbcddaae3e66a9f63b58640208dad533664
7
- data.tar.gz: 1f6e543316862883b4da9e577d43993f87a7904854b9ea96754f6b78d74f354e39bd452d6634c65845ac53056e28a28cb16c5083972de68e7393c8cd852d4965
6
+ metadata.gz: ffbf5af184d03bd16d6967046a833c7793a28395017e4a175ad2b6a67f56661e9ef387fd6a5fe7b951b75b7186ff3dc531bab2964afda1b43f589279b8277abc
7
+ data.tar.gz: '019aab7a1b1d5784a5d7a498557fdba3c0af0df7e7b312e9fb96cfb9ef2214e7c3f341a2cfb82fad931a0b6afe1d26e66b66baba7ba04c1001cf4d742284ef3f'
@@ -12,6 +12,13 @@ module Nylas
12
12
  class ModelNotUpdatableError < ModelActionError; end
13
13
  class ModelNotDestroyableError < ModelActionError; end
14
14
 
15
+ # Raised when attempting to set a field that is not on a model with mass assignment
16
+ class ModelMissingFieldError < ModelActionError
17
+ def initialize(field, model)
18
+ super("#{field} is not a valid attribute for #{model.class.name}")
19
+ end
20
+ end
21
+
15
22
  # Indicates that a given method needs an access token to work.
16
23
  class NoAuthToken < Error
17
24
  def initialize(method_name)
@@ -48,6 +48,8 @@ module Nylas
48
48
  attributes.merge(**data)
49
49
  execute(method: :put, payload: attributes.serialize(keys: data.keys), path: resource_path)
50
50
  true
51
+ rescue Registry::MissingKeyError => e
52
+ raise ModelMissingFieldError.new(e.key, self)
51
53
  end
52
54
 
53
55
  def reload
@@ -8,7 +8,11 @@ module Nylas
8
8
 
9
9
  def initialize(**initial_data)
10
10
  initial_data.each do |attribute_name, value|
11
- send(:"#{attribute_name}=", value)
11
+ if self.class.attribute_definitions.key?(attribute_name)
12
+ send(:"#{attribute_name}=", value)
13
+ else
14
+ Logging.logger.warn("#{attribute_name} is not defined as an attribute on #{self.class.name}")
15
+ end
12
16
  end
13
17
  end
14
18
 
@@ -5,14 +5,16 @@ module Nylas
5
5
  # Used to indicate an attempt to retrieve something not yet registered in a registry
6
6
  # Includes the list of keys in the registry for debug purposes.
7
7
  class MissingKeyError < Error
8
+ attr_accessor :key
8
9
  def initialize(key, keys)
9
10
  super("key #{key} not in #{keys}")
11
+ self.key = key
10
12
  end
11
13
  end
12
14
  attr_accessor :registry_data
13
15
 
14
16
  extend Forwardable
15
- def_delegators :registry_data, :keys, :each, :reduce
17
+ def_delegators :registry_data, :keys, :each, :reduce, :key?
16
18
 
17
19
  def initialize(initial_data = {})
18
20
  self.registry_data = initial_data.each.each_with_object({}) do |(key, value), registry|
@@ -1,3 +1,3 @@
1
1
  module Nylas
2
- VERSION = "4.2.1".freeze
2
+ VERSION = "4.2.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nylas
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.1
4
+ version: 4.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nylas, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-21 00:00:00.000000000 Z
11
+ date: 2018-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -320,7 +320,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
320
320
  version: '0'
321
321
  requirements: []
322
322
  rubyforge_project:
323
- rubygems_version: 2.5.2
323
+ rubygems_version: 2.6.13
324
324
  signing_key:
325
325
  specification_version: 4
326
326
  summary: Gem for interacting with the Nylas API