azahara_schema 0.1.5 → 0.1.6
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 +4 -4
- data/lib/azahara_schema/attribute.rb +9 -4
- data/lib/azahara_schema/field_format.rb +4 -0
- data/lib/azahara_schema/schema.rb +5 -4
- data/lib/azahara_schema/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: 4390fbc505e535b317928c28dae0a13d99ec7997
|
4
|
+
data.tar.gz: 8fab75c50ea5623a6f29f812d6575a7e03177da4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e318854db84d703d99076e572909ccc09480b632f62bcc0f8306eb35e00371e803b1ae52b8be64f0b1a90bc0628802b614b2613d7e87744e00d5b6bc9245e483
|
7
|
+
data.tar.gz: dde84cf9dc5573525fc7b2b2f740b162ba339fc8a686f1c906d3873e782af4b8e26b154df91a81ca9288e75cc6b2ad54af994e11e4eda0debb289a17a6dd07ea
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'azahara_schema/field_format'
|
2
|
+
|
1
3
|
module AzaharaSchema
|
2
4
|
class Attribute
|
3
5
|
attr_accessor :name, :format, :model
|
@@ -58,15 +60,18 @@ module AzaharaSchema
|
|
58
60
|
end
|
59
61
|
|
60
62
|
def add_statement(scope, operator, values)
|
63
|
+
values = [values] unless values.is_a?(Array)
|
61
64
|
case operator
|
62
65
|
when '='
|
63
|
-
scope.where( arel_field.
|
66
|
+
scope.where( arel_field.in(values) )
|
64
67
|
when '~'
|
65
|
-
|
68
|
+
arl = arel_field.matches("%#{values[0]}%")
|
69
|
+
values[1..-1].each{|v| arl = arl.or( arel_field.matches("%#{v}%") ) }
|
70
|
+
scope.where( arl )
|
66
71
|
when '>='
|
67
|
-
scope.where( arel_field.gteq(values) )
|
72
|
+
scope.where( arel_field.gteq(values.map(&:to_f).min) )
|
68
73
|
when '<='
|
69
|
-
scope.where( arel_field.lteq(values) )
|
74
|
+
scope.where( arel_field.lteq(values.map(&:to_f).max) )
|
70
75
|
else
|
71
76
|
throw 'Unknown operator ' + operator.to_s
|
72
77
|
end
|
@@ -83,10 +83,11 @@ module AzaharaSchema
|
|
83
83
|
def add_short_filter(name, str)
|
84
84
|
attrs = str.split('|')
|
85
85
|
if attrs.size == 2
|
86
|
-
|
86
|
+
operator, values = attrs
|
87
87
|
elsif attrs.size == 1
|
88
|
-
|
88
|
+
operator, values = '=', attrs.first
|
89
89
|
end
|
90
|
+
add_filter(name, operator, values.split('\\'))
|
90
91
|
end
|
91
92
|
|
92
93
|
def add_filter(name, operator, values)
|
@@ -156,8 +157,8 @@ module AzaharaSchema
|
|
156
157
|
|
157
158
|
def available_associations
|
158
159
|
@available_associations ||= model.reflect_on_all_associations.select do |association|
|
159
|
-
association.
|
160
|
-
|
160
|
+
!association.options[:polymorphic] &&
|
161
|
+
association.klass != model &&
|
161
162
|
!association_path.include?( association.name.to_s.singularize.to_sym ) &&
|
162
163
|
!association_path.include?( association.name.to_s.pluralize.to_sym )
|
163
164
|
end.collect do |association|
|
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.6
|
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-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|