jet_set 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jet_set/dependency_graph.rb +1 -1
- data/lib/jet_set/entity_mapping.rb +5 -3
- data/lib/jet_set/mapper.rb +5 -2
- data/lib/jet_set/mixin/entity.rb +5 -1
- data/lib/jet_set/reference.rb +7 -1
- data/lib/jet_set/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d9c31fea3ab85535b7334a1bcfea9f5a15577f6
|
4
|
+
data.tar.gz: 9dff8880d96dc20c7674a64e66553ac104da18be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23b7ed643ec6ad827879e7d6f2e1e9d0f038a78cd7051483de3c85f6ea1f32d02361d098ecbeab6648375b5d206367028bdd16310ca8a11bd76962ece12b0258
|
7
|
+
data.tar.gz: c59832f80bbf2996665384963be940e81ae9bc26a68a28f6d5bb212e28c1899710c544cfb5eeff48564e5a9a7458453eddaa475708d5ad11809a765111bb8964
|
@@ -5,7 +5,7 @@ module JetSet
|
|
5
5
|
# Entity mapping is an element of JetSet mapping definition, see +JetSet::Mapping+.
|
6
6
|
# Should be instantiated by method +entity+ of +JetSet::Mapping+ instance.
|
7
7
|
class EntityMapping
|
8
|
-
attr_reader :references, :collections, :fields, :type, :dependencies
|
8
|
+
attr_reader :references, :collections, :fields, :type, :dependencies, :relations
|
9
9
|
|
10
10
|
# Initializes the mapping using Ruby block.
|
11
11
|
# Parameters:
|
@@ -15,7 +15,8 @@ module JetSet
|
|
15
15
|
@type = type
|
16
16
|
@references = {}
|
17
17
|
@collections = {}
|
18
|
-
@dependencies = []
|
18
|
+
@dependencies = [] # stores only strong dependencies
|
19
|
+
@relations = [] # stores all dependencies
|
19
20
|
@fields = ['id']
|
20
21
|
|
21
22
|
if block_given?
|
@@ -42,8 +43,9 @@ module JetSet
|
|
42
43
|
raise MapperError, "Reference \"#{name}\" should have a type. Example:\n reference '#{name}', type: User\n"
|
43
44
|
end
|
44
45
|
|
45
|
-
@references[name] = Reference.new(name, params[:type])
|
46
|
+
@references[name] = Reference.new(name, params[:type], params[:weak])
|
46
47
|
@dependencies << params[:type] unless params[:weak]
|
48
|
+
@relations << params[:type]
|
47
49
|
end
|
48
50
|
|
49
51
|
# Defines an attribute-collection of a complex type - another entity defined in the mapping.
|
data/lib/jet_set/mapper.rb
CHANGED
@@ -37,8 +37,11 @@ module JetSet
|
|
37
37
|
|
38
38
|
row.reference_names.each do |reference_name|
|
39
39
|
if entity_mapping.references.key? reference_name.to_sym
|
40
|
-
|
41
|
-
|
40
|
+
reference_id_name = reference_name + '__id'
|
41
|
+
unless row_hash[reference_id_name.to_sym].nil?
|
42
|
+
type = entity_mapping.references[reference_name.to_sym].type
|
43
|
+
entity.set_reference! reference_name, map(type, row_hash, session, reference_name)
|
44
|
+
end
|
42
45
|
end
|
43
46
|
end
|
44
47
|
|
data/lib/jet_set/mixin/entity.rb
CHANGED
@@ -97,12 +97,16 @@ module JetSet
|
|
97
97
|
|
98
98
|
entity.references.keys.each do |key|
|
99
99
|
value = instance_variable_get("@#{key}")
|
100
|
+
reference = entity.references[key]
|
101
|
+
|
100
102
|
if value
|
101
103
|
reference_id = value.instance_variable_get('@id')
|
102
|
-
|
104
|
+
|
105
|
+
if reference_id.nil? && !reference.weak?
|
103
106
|
@__factory.create(value)
|
104
107
|
value.flush(sequel)
|
105
108
|
end
|
109
|
+
|
106
110
|
set_reference!(key, value)
|
107
111
|
fields << "#{key}_id"
|
108
112
|
|
data/lib/jet_set/reference.rb
CHANGED
@@ -7,9 +7,15 @@ module JetSet
|
|
7
7
|
# Parameters:
|
8
8
|
# +name+:: name of the attribute
|
9
9
|
# +type+:: class of an entity
|
10
|
-
|
10
|
+
# +weak+:: is it weak reference?
|
11
|
+
def initialize(name, type, weak)
|
11
12
|
@name = name
|
12
13
|
@type = type
|
14
|
+
@weak = weak
|
15
|
+
end
|
16
|
+
|
17
|
+
def weak?
|
18
|
+
@weak
|
13
19
|
end
|
14
20
|
end
|
15
21
|
end
|
data/lib/jet_set/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jet_set
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Kalinkin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|