tallty_duck_record 1.0.1 → 1.0.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: 13519264c45683755376962602255447fa0c917fa664135794691b73883cb494
4
- data.tar.gz: f28955103e902cba1ee4b89de063eeea2031f07e902ede4883133c05c1c7c058
3
+ metadata.gz: cdacef587e1cfa12ab54ac67ab5fb6ce307e31a6ac0c8050a0244027a9893054
4
+ data.tar.gz: 70901e85b01c40941c75d69393d71e8d661154e5038d5f704d4736c00deb4bd6
5
5
  SHA512:
6
- metadata.gz: 865d2b950b25104831ab58ff1476701ea7460217009f36e5062af8c502f5a58007041e113297d0e64d898c9f5037d1696a704ba035f9b3e5c860ccbafa6522c9
7
- data.tar.gz: 439833d5a4fc1bc51a35c21f0363fa9852e59c11bc5a4df296286a4753028249dbc3f38a18c52420ab28774887d2b652cc0f44df9406d93e804a9209e6004ffe
6
+ metadata.gz: 54f125385506413b6d1a9a338b701c348408e36e3d4b2c26e7c1df91eabe5baab2be770731c9f03d69eac36dbf50f0223c435606df649139f1192f785df37581
7
+ data.tar.gz: 83bc69b8e73ac5788dc327b795ec65440f1642f0c6b10114d866953e257590e1e44eb7a97ecbc0e30ce864fc519cbf081714ad9145531626e2cb7d0cff603243
@@ -1,7 +1,9 @@
1
- class MetaRecord < MetaStrictRecord
2
- def _assign_attribute(k, v)
3
- if respond_to?("#{k}=")
4
- public_send("#{k}=", v)
1
+ module DuckRecord
2
+ class MetaRecord < MetaStrictRecord
3
+ def _assign_attribute(k, v)
4
+ if respond_to?("#{k}=")
5
+ public_send("#{k}=", v)
6
+ end
5
7
  end
6
8
  end
7
9
  end
@@ -1,38 +1,39 @@
1
- class MetaStrictRecord < DuckRecord::Base
2
- attr_accessor :raw_attributes
1
+ module DuckRecord
2
+ class MetaStrictRecord < DuckRecord::Base
3
+ attr_accessor :raw_attributes
3
4
 
4
- def serializable_hash(options = {})
5
- options = (options || {}).reverse_merge include: self.class._embeds_reflections.keys
6
- super options
7
- end
8
-
9
- class << self
10
- def _embeds_reflections
11
- _reflections.select { |_, v| v.is_a? DuckRecord::Reflection::EmbedsAssociationReflection }
5
+ def serializable_hash(options = {})
6
+ options = (options || {}).reverse_merge include: self.class._embeds_reflections.keys
7
+ super options
12
8
  end
13
9
 
14
- def dump(obj)
15
- serializable_hash =
16
- if obj.respond_to?(:serializable_hash)
17
- obj.serializable_hash
18
- elsif obj.respond_to?(:to_hash)
19
- obj.to_hash
20
- else
21
- raise ArgumentError, "`obj` required can be cast to `Hash` -- #{obj.class}"
22
- end.stringify_keys
23
- return serializable_hash
24
- end
10
+ class << self
11
+ def _embeds_reflections
12
+ _reflections.select { |_, v| v.is_a? DuckRecord::Reflection::EmbedsAssociationReflection }
13
+ end
25
14
 
26
- def load(hash)
27
- case hash
28
- when Hash
29
- record = new hash
30
- record.raw_attributes = hash.with_indifferent_access
31
- return record
32
- else
33
- new
15
+ def dump(obj)
16
+ serializable_hash =
17
+ if obj.respond_to?(:serializable_hash)
18
+ obj.serializable_hash
19
+ elsif obj.respond_to?(:to_hash)
20
+ obj.to_hash
21
+ else
22
+ raise ArgumentError, "`obj` required can be cast to `Hash` -- #{obj.class}"
23
+ end.stringify_keys
24
+ return serializable_hash
25
+ end
26
+
27
+ def load(hash)
28
+ case hash
29
+ when Hash
30
+ record = new hash
31
+ record.raw_attributes = hash.with_indifferent_access
32
+ return record
33
+ else
34
+ new
35
+ end
34
36
  end
35
37
  end
36
38
  end
37
39
  end
38
-
@@ -1,3 +1,3 @@
1
1
  module DuckRecord
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tallty_duck_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - tallty