fastapi 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastapi.rb +28 -20
- data/lib/fastapi/active_record_extension.rb +12 -0
- 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: 0af071723d04b7cb79104f53f4d800278380524a
|
4
|
+
data.tar.gz: 9841776f060fcdfa5f121f6f7cb162c0df45f557
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73a147f323c7ce14b43316cead922a31ff1bd1934c17749646201c71c94493f5ed926ce76571b628890d7d4405701add9d7957d46d7a4f0157a1e456dcfa6454
|
7
|
+
data.tar.gz: 2614da3a0b1d1537bc9d67460f42831b27fc1651d2dc25ef1a728d50e6e1c181492dc779a45709c27c81fa6f96f05fbaed7fab898b4aea96027a3225af35d84c
|
data/lib/fastapi.rb
CHANGED
@@ -556,30 +556,38 @@ class FastAPI
|
|
556
556
|
|
557
557
|
if key == :__order
|
558
558
|
|
559
|
-
|
559
|
+
if model.nil? and (value.is_a? String or value.is_a? Symbol) and @model.fastapi_custom_order.has_key? value.to_sym
|
560
560
|
|
561
|
-
|
562
|
-
order = order.split(',')
|
563
|
-
if order.size < 2
|
564
|
-
order << 'ASC'
|
565
|
-
end
|
566
|
-
elsif order.is_a? Array
|
567
|
-
order = order.map { |v| v.to_s }
|
568
|
-
while order.size < 2
|
569
|
-
order << ''
|
570
|
-
end
|
571
|
-
else
|
572
|
-
order = ['', '']
|
573
|
-
end
|
561
|
+
order = @model.fastapi_custom_order[value.to_sym].gsub('self.', self_string_table + '.')
|
574
562
|
|
575
|
-
if not self_obj.column_names.include? order[0]
|
576
|
-
order = nil
|
577
563
|
else
|
578
|
-
|
579
|
-
|
580
|
-
|
564
|
+
|
565
|
+
order = value.clone()
|
566
|
+
|
567
|
+
if order.is_a? String
|
568
|
+
order = order.split(',')
|
569
|
+
if order.size < 2
|
570
|
+
order << 'ASC'
|
571
|
+
end
|
572
|
+
elsif order.is_a? Array
|
573
|
+
order = order.map { |v| v.to_s }
|
574
|
+
while order.size < 2
|
575
|
+
order << ''
|
576
|
+
end
|
577
|
+
else
|
578
|
+
order = ['', '']
|
581
579
|
end
|
582
|
-
|
580
|
+
|
581
|
+
if not self_obj.column_names.include? order[0]
|
582
|
+
order = nil
|
583
|
+
else
|
584
|
+
order[0] = self_string_table + '.' + order[0]
|
585
|
+
if not ['ASC', 'DESC'].include? order[1]
|
586
|
+
order[1] = 'ASC'
|
587
|
+
end
|
588
|
+
order = order.join(' ')
|
589
|
+
end
|
590
|
+
|
583
591
|
end
|
584
592
|
|
585
593
|
else
|
@@ -38,6 +38,18 @@ module FastAPIExtension
|
|
38
38
|
@fastapi_filters = filters
|
39
39
|
end
|
40
40
|
|
41
|
+
# Define custom ORDER BY strings for specific keys
|
42
|
+
#
|
43
|
+
# @param keys [Hash] a hash containing the keys: strings for order filters
|
44
|
+
# @return [Hash] the same keys hash
|
45
|
+
def fastapi_define_order(keys)
|
46
|
+
@fastapi_custom_order = keys
|
47
|
+
end
|
48
|
+
|
49
|
+
def fastapi_custom_order
|
50
|
+
@fastapi_custom_order or {}
|
51
|
+
end
|
52
|
+
|
41
53
|
def fastapi_fields
|
42
54
|
@fastapi_fields or [:id]
|
43
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Horwood
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|