fastapi 0.1.15 → 0.1.16
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/fastapi.rb +9 -54
- 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: af20b323da9210dc71e62a30ea44667d3376da1d
|
4
|
+
data.tar.gz: f3de2e210499133ad71a998657e28f0f7b817191
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55fbc45d21255e8a7a6090f3eb86d6dae5299074ac91f352c1343567a99f95130c06e14020a8777c5306dd1b30496e01960990dddde483d332a8aba08f1b30a5
|
7
|
+
data.tar.gz: 208b4dc1fe024a49a84b20476faee6b1935302f4e54e36cf7da6f3dfa354cd89c9874fb098131da4b0694c882e83b53d66255a31df13566401189e601ac44a73
|
data/lib/fastapi.rb
CHANGED
@@ -27,7 +27,6 @@ class FastAPI
|
|
27
27
|
@model = model
|
28
28
|
@data = nil
|
29
29
|
@metadata = nil
|
30
|
-
@has_results = false
|
31
30
|
@result_type = 0
|
32
31
|
end
|
33
32
|
|
@@ -41,9 +40,9 @@ class FastAPI
|
|
41
40
|
# @param filters [Hash] a hash containing the intended filters
|
42
41
|
# @param meta [Hash] a hash containing custom metadata
|
43
42
|
# @return [FastAPI] the current instance
|
44
|
-
def filter(filters = {}, meta = {})
|
43
|
+
def filter(filters = {}, meta = {}, safe = false)
|
45
44
|
|
46
|
-
result = fastapi_query(filters)
|
45
|
+
result = fastapi_query(filters, safe)
|
47
46
|
|
48
47
|
metadata = {}
|
49
48
|
|
@@ -73,23 +72,7 @@ class FastAPI
|
|
73
72
|
# @return [FastAPI] the current instance
|
74
73
|
def safe_filter(filters = {}, meta = {})
|
75
74
|
|
76
|
-
|
77
|
-
|
78
|
-
metadata = {}
|
79
|
-
|
80
|
-
meta.each do |key, value|
|
81
|
-
metadata[key] = value
|
82
|
-
end
|
83
|
-
|
84
|
-
metadata[:total] = result[:total]
|
85
|
-
metadata[:offset] = result[:offset]
|
86
|
-
metadata[:count] = result[:count]
|
87
|
-
metadata[:error] = result[:error]
|
88
|
-
|
89
|
-
@metadata = metadata
|
90
|
-
@data = result[:data]
|
91
|
-
|
92
|
-
@result_type = @@result_types[:multiple]
|
75
|
+
filter(filters, meta, true)
|
93
76
|
|
94
77
|
self
|
95
78
|
|
@@ -103,30 +86,12 @@ class FastAPI
|
|
103
86
|
# @return [FastAPI] the current instance
|
104
87
|
def fetch(id, meta = {})
|
105
88
|
|
106
|
-
|
107
|
-
|
108
|
-
metadata = {}
|
109
|
-
|
110
|
-
meta.each do |key, value|
|
111
|
-
metadata[key] = value
|
112
|
-
end
|
89
|
+
filter({id: id}, meta)
|
113
90
|
|
114
|
-
if
|
115
|
-
error = {message: @model.to_s + ' id does not exist'}
|
116
|
-
else
|
117
|
-
error = result[:error]
|
91
|
+
if @metadata[:total] == 0
|
92
|
+
@metadata[:error] = {message: @model.to_s + ' id does not exist'}
|
118
93
|
end
|
119
94
|
|
120
|
-
metadata[:total] = result[:total]
|
121
|
-
metadata[:offset] = result[:offset]
|
122
|
-
metadata[:count] = result[:count]
|
123
|
-
metadata[:error] = error
|
124
|
-
|
125
|
-
@metadata = metadata
|
126
|
-
@data = result[:data]
|
127
|
-
|
128
|
-
@result_type = @@result_types[:multiple]
|
129
|
-
|
130
95
|
self
|
131
96
|
|
132
97
|
end
|
@@ -656,10 +621,6 @@ class FastAPI
|
|
656
621
|
|
657
622
|
if model.nil?
|
658
623
|
|
659
|
-
puts 'What the Fuck'
|
660
|
-
puts key
|
661
|
-
puts self_obj
|
662
|
-
|
663
624
|
if self_obj.reflect_on_all_associations(:has_many).map(&:name).include? key
|
664
625
|
|
665
626
|
filter_result = parse_filters(value, safe, field.singularize.classify.constantize)
|
@@ -764,19 +725,13 @@ class FastAPI
|
|
764
725
|
class_name = @model.reflect_on_association(field).options[:class_name]
|
765
726
|
|
766
727
|
if class_name.nil?
|
767
|
-
|
768
728
|
model = field.to_s.classify.constantize
|
769
|
-
model_lookup[field] = model
|
770
|
-
belongs << {model: model, alias: field}
|
771
|
-
|
772
729
|
else
|
773
|
-
|
774
730
|
model = class_name.constantize
|
775
|
-
model_lookup[field] = model
|
776
|
-
|
777
|
-
belongs << {model: model, alias: field}
|
778
|
-
|
779
731
|
end
|
732
|
+
|
733
|
+
model_lookup[field] = model
|
734
|
+
belongs << {model: model, alias: field}
|
780
735
|
|
781
736
|
elsif @model.reflect_on_all_associations(:has_many).map(&:name).include? field
|
782
737
|
model = field.to_s.singularize.classify.constantize
|
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.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Horwood
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|