tallty_duck_record 1.0.0 → 1.1.2
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.rb +2 -0
- data/lib/duck_record/base.rb +15 -14
- data/lib/duck_record/meta_record.rb +9 -0
- data/lib/duck_record/meta_strict_record.rb +39 -0
- data/lib/duck_record/version.rb +1 -1
- metadata +16 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e76c47a46726cc7d60f7386b25dd5d14fb70127f6dca09e825c745b00679ace1
|
4
|
+
data.tar.gz: 046df1437a032edf1aaf1c19866fccd84c5388435247c1cfd5c60f9f632ad321
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 523d863290eec53bb5edc68fa360499b631a7301a193c17f63f43602548e45e2064be496b8e60bcaacefff8d35b4b34ecff3d682b4b5d8bf2b4c32832721df18
|
7
|
+
data.tar.gz: f054891f0c2f22d10fc56c18a7bdc8d106280972a85dedb7adcde3752e9aabb6715507473336b0e50acc13ceeee7d1da59f058c1d6da6a9701aa666c64a3ef38
|
data/lib/duck_record.rb
CHANGED
data/lib/duck_record/base.rb
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
require "yaml"
|
2
|
-
require
|
3
|
-
require "active_support/
|
4
|
-
require "active_support/
|
5
|
-
require "active_support/
|
6
|
-
require "active_support/
|
7
|
-
require "active_support/core_ext/
|
8
|
-
require "active_support/core_ext/
|
9
|
-
require "active_support/core_ext/hash/
|
10
|
-
require "active_support/core_ext/hash/
|
11
|
-
require "active_support/core_ext/
|
12
|
-
require "active_support/core_ext/
|
13
|
-
require "active_support/core_ext/
|
14
|
-
require "active_support/core_ext/
|
15
|
-
require "active_support/core_ext/
|
2
|
+
require 'active_support'
|
3
|
+
# require "active_support/benchmarkable"
|
4
|
+
# require "active_support/dependencies"
|
5
|
+
# require "active_support/descendants_tracker"
|
6
|
+
# require "active_support/time"
|
7
|
+
# require "active_support/core_ext/module/attribute_accessors"
|
8
|
+
# require "active_support/core_ext/array/extract_options"
|
9
|
+
# require "active_support/core_ext/hash/deep_merge"
|
10
|
+
# require "active_support/core_ext/hash/slice"
|
11
|
+
# # require "active_support/core_ext/hash/transform_values"
|
12
|
+
# require "active_support/core_ext/string/behavior"
|
13
|
+
# require "active_support/core_ext/kernel/singleton_class"
|
14
|
+
# require "active_support/core_ext/module/introspection"
|
15
|
+
# require "active_support/core_ext/object/duplicable"
|
16
|
+
# require "active_support/core_ext/class/subclasses"
|
16
17
|
require "duck_record/define_callbacks"
|
17
18
|
require "duck_record/errors"
|
18
19
|
require "duck_record/attributes"
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module DuckRecord
|
2
|
+
class MetaStrictRecord < DuckRecord::Base
|
3
|
+
attr_accessor :raw_attributes
|
4
|
+
|
5
|
+
def serializable_hash(options = {})
|
6
|
+
options = (options || {}).reverse_merge include: self.class._embeds_reflections.keys
|
7
|
+
super options
|
8
|
+
end
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def _embeds_reflections
|
12
|
+
_reflections.select { |_, v| v.is_a? DuckRecord::Reflection::EmbedsAssociationReflection }
|
13
|
+
end
|
14
|
+
|
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
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
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.2
|
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
|
@@ -127,6 +127,8 @@ files:
|
|
127
127
|
- lib/duck_record/errors.rb
|
128
128
|
- lib/duck_record/inheritance.rb
|
129
129
|
- lib/duck_record/locale/en.yml
|
130
|
+
- lib/duck_record/meta_record.rb
|
131
|
+
- lib/duck_record/meta_strict_record.rb
|
130
132
|
- lib/duck_record/model_schema.rb
|
131
133
|
- lib/duck_record/nested_attributes.rb
|
132
134
|
- lib/duck_record/nested_validate_association.rb
|