tallty_duck_record 1.0.1 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/duck_record/meta_record.rb +6 -4
- data/lib/duck_record/meta_strict_record.rb +31 -30
- data/lib/duck_record/version.rb +1 -1
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 036c3954f67fb6dd302c710328b6fbaf05916a84d6b83d95ea93fea075eca36a
|
4
|
+
data.tar.gz: 98a19e78d57229b8108f855c4173f5889fc35d8e34560e8cd62f4d490c06b424
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ac3b352bcdd28577839b900d0bee2b2f8409a532ea8deb4a638be7440abae84435e53d78c01a682dc0155af6b81d09f06ec700b4e1036cd89e9dd8af76b6cf2
|
7
|
+
data.tar.gz: ea0ebfbc42e4a9841c8d55ae9a368db23c5ea5c044b497fcbfbfd4f329cfaa964c86522bc106c7bf59fcc6e4021e3c534fec3962f62ffd19afc5bd6c9529afb5
|
@@ -1,7 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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
|
-
|
2
|
-
|
1
|
+
module DuckRecord
|
2
|
+
class MetaStrictRecord < DuckRecord::Base
|
3
|
+
attr_accessor :raw_attributes
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
data/lib/duck_record/version.rb
CHANGED
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tallty_duck_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tallty
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '5.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activemodel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '5.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '5.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '5.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '5.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: sqlite3
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|