reynard 0.8.1 → 0.8.2

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
  SHA256:
3
- metadata.gz: 2942c304a1a9caaae88253e2bce40188b79bb8a5d25ccd93c8e9a04f7730e386
4
- data.tar.gz: 12948419634f2926ae083ae364bd35f48a6b79b8f6308df95b80baafe061dce6
3
+ metadata.gz: cf9800ba5e9413a1b15f0e7ba1a670b445c3bd3ad17d4d4229b68f9edbb1d2ce
4
+ data.tar.gz: 28dffe4ecfc842642f88d8d091e0acfb7b11f706a80504f2e9caf0fd983a0695
5
5
  SHA512:
6
- metadata.gz: 2bcf669808d10dfff594861274b301ff77c99038ddea5e121b0ccd61336beb7089e6c20f4e566c9a29e5b813194f5b79d07c7c067c720b6b303de8c07e862944
7
- data.tar.gz: 64f7877a9a9e44c77cb357ff36d2ecac691cfce668dc2ba2197f0b68a284e0127fab96c099ca3cb99c0390658466a4fcda3569a2e2479e643d73f95d06cf2a16
6
+ metadata.gz: 272402519908855f09f368efa5d3e0e85791e48b5f86bd2ddee66b8418aea9f686192ca7bacc1eae233b87fc6b821303f3771a8e784bc762a028d22bc2520058
7
+ data.tar.gz: 17481196746340a8caed347dc249cd4e2c59b421e999edc50700631741d4aa4ce2a8c4577e8b41fc61ba2feeb0cc22f2b4d86c321d532d26c8d3c1291606ba6a
data/lib/reynard/model.rb CHANGED
@@ -14,9 +14,17 @@ class Reynard
14
14
  end
15
15
 
16
16
  def initialize(attributes)
17
- @attributes = {}
18
- @snake_cases = self.class.snake_cases(attributes.keys)
19
- self.attributes = attributes
17
+ if attributes.respond_to?(:each)
18
+ @attributes = {}
19
+ @snake_cases = self.class.snake_cases(attributes.keys)
20
+ self.attributes = attributes
21
+ else
22
+ raise(
23
+ ArgumentError,
24
+ 'Models must be initialized with an enumerable object that behaves like a hash, got: ' \
25
+ "`#{attributes.inspect}'"
26
+ )
27
+ end
20
28
  end
21
29
 
22
30
  def attributes=(attributes)
@@ -47,6 +55,7 @@ class Reynard
47
55
  end
48
56
 
49
57
  def self.cast(name, value)
58
+ return if value.nil?
50
59
  return value unless schema
51
60
 
52
61
  property = schema.property_schema(name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Reynard
4
- VERSION = '0.8.1'
4
+ VERSION = '0.8.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reynard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manfred Stienstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-14 00:00:00.000000000 Z
11
+ date: 2023-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json