azahara_schema 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af8c74a55165b64dd1028655871bbccd2df367faf7f8e140c2574d5e3823260c
|
4
|
+
data.tar.gz: 2b066a64fe4b33863562dad9d13c38dad1cd73f5460368f057851ef3dc873ab7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e68614299630ffafb7d870b3a8aea26df55ddccd8bea8ea5deaeebfcea6e1b2f76364c9b45a3b435ccaebf4b613f7ce824d52fb1e2721bc99866dab91394a784
|
7
|
+
data.tar.gz: 22bd14b10428e52aa5d61ccd404cc8ae892264548842c780abcecdd7bb9f19b4a72eddedfe1c34c9e0d10940d72fde20683664c4485cfde0fbc04028838e3f60
|
@@ -55,12 +55,27 @@ module AzaharaSchema
|
|
55
55
|
{ association.name => attribute.association_hash }
|
56
56
|
end
|
57
57
|
|
58
|
+
def arel_join(parent=nil, join_type=::Arel::Nodes::OuterJoin, a_tbl=self.arel_table)
|
59
|
+
parent ||= a_tbl
|
60
|
+
joined = parent
|
61
|
+
case association.macro
|
62
|
+
when :has_many, :has_one
|
63
|
+
joined = parent.join(attribute.arel_table, join_type).on( attribute.arel_table[association.foreign_key].eq( a_tbl[model.primary_key] ) )
|
64
|
+
when :belongs_to
|
65
|
+
joined = parent.join(attribute.arel_table, join_type).on( attribute.arel_table[attribute.model.primary_key].eq( a_tbl[association.foreign_key] ) )
|
66
|
+
else
|
67
|
+
raise 'Unknown macro ' + association.macro.to_s
|
68
|
+
end
|
69
|
+
attribute.arel_join( joined )
|
70
|
+
end
|
71
|
+
|
58
72
|
def arel_statement(operator, values)
|
59
73
|
attribute.arel_statement(operator, values)
|
60
74
|
end
|
61
75
|
|
62
76
|
def add_join(scope)
|
63
|
-
scope.
|
77
|
+
# scope.left_outer_joins(association_hash)
|
78
|
+
scope.joins(arel_join.join_sources)
|
64
79
|
end
|
65
80
|
|
66
81
|
def add_preload(scope)
|
@@ -2,7 +2,7 @@ require 'azahara_schema/field_format'
|
|
2
2
|
|
3
3
|
module AzaharaSchema
|
4
4
|
class Attribute
|
5
|
-
attr_accessor :name, :format, :model
|
5
|
+
attr_accessor :name, :format, :model, :table_alias
|
6
6
|
|
7
7
|
def initialize(model, name, type)
|
8
8
|
@name, @model = name, model
|
@@ -26,8 +26,12 @@ module AzaharaSchema
|
|
26
26
|
format.format_name
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
model.arel_table
|
29
|
+
def arel_table(t_alias=self.table_alias)
|
30
|
+
t_alias ? model.arel_table.alias(t_alias) : model.arel_table
|
31
|
+
end
|
32
|
+
|
33
|
+
def arel_field(t_alias=self.table_alias)
|
34
|
+
arel_table(t_alias)[filter_name]
|
31
35
|
end
|
32
36
|
|
33
37
|
def arel_sort_field
|
@@ -111,5 +115,9 @@ module AzaharaSchema
|
|
111
115
|
{}
|
112
116
|
end
|
113
117
|
|
118
|
+
def arel_join(parent=nil, join_type=::Arel::Nodes::OuterJoin, a_tbl=self.arel_table(self.table_alias))
|
119
|
+
parent
|
120
|
+
end
|
121
|
+
|
114
122
|
end
|
115
123
|
end
|
@@ -125,6 +125,7 @@ module AzaharaSchema
|
|
125
125
|
def available_attributes
|
126
126
|
unless @available_attributes
|
127
127
|
initialize_available_attributes
|
128
|
+
@available_attributes.each{|at| at.table_alias = Array(association_path[1..-1]).collect(&:to_s).join('_').presence }
|
128
129
|
end
|
129
130
|
@available_attributes
|
130
131
|
end
|
@@ -157,7 +158,7 @@ module AzaharaSchema
|
|
157
158
|
end
|
158
159
|
|
159
160
|
def association_path
|
160
|
-
@association_path ||= parent_schema ? ( [association.name]
|
161
|
+
@association_path ||= parent_schema ? ( parent_schema.association_path + [association.name] ) : [model.model_name.element.to_sym]
|
161
162
|
end
|
162
163
|
|
163
164
|
def available_associations
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: azahara_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondřej Ezr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
100
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.7.
|
101
|
+
rubygems_version: 2.7.2
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: Gem to support developement of rails application with schema over an entity
|