quick_api 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/quick_api/mongoid.rb +24 -24
- data/lib/quick_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc2ddbe6616c14dee21e36716a869e90b5620fc7
|
4
|
+
data.tar.gz: f0b6b4d65ed00d7f0000e60251fbbf030835c676
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cc17f97d1b757fda40054563fac9979498800b97f799408624ab6b900baa007fc4d4be4a6337a8188b46942427985f3dab4a09f0d8c205b00a334f058f5cc2f
|
7
|
+
data.tar.gz: eb1484439dcd2074865c1b6a11cca07b7872b1e178ca685fc5cd24a414d5bf6538997c2cf7655702cac6b0ec43399fb919513010a4bb22335acf032f304689a8
|
data/Gemfile.lock
CHANGED
data/lib/quick_api/mongoid.rb
CHANGED
@@ -3,49 +3,49 @@ module QuickApi
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
class_attribute :quick_api_attributes
|
7
6
|
# class_attribute :quick_api_methods
|
8
|
-
class_attribute :
|
9
|
-
class_attribute :
|
10
|
-
class_attribute :
|
11
|
-
class_attribute :
|
12
|
-
class_attribute :
|
13
|
-
class_attribute :
|
14
|
-
class_attribute :
|
7
|
+
class_attribute :q_api_attributes
|
8
|
+
class_attribute :q_api_has_many
|
9
|
+
class_attribute :q_api_belongs_to
|
10
|
+
class_attribute :q_api_has_one
|
11
|
+
class_attribute :q_api_has_and_belongs_to_many
|
12
|
+
class_attribute :q_api_embeds_many
|
13
|
+
class_attribute :q_api_embedded_in
|
14
|
+
class_attribute :q_api_embeds_one
|
15
15
|
end
|
16
16
|
|
17
17
|
module ClassMethods
|
18
18
|
|
19
19
|
def quick_api_attributes(*names)
|
20
|
-
self.
|
20
|
+
self.q_api_attributes = names
|
21
21
|
end
|
22
22
|
|
23
23
|
def quick_api_has_many(*relations)
|
24
|
-
self.
|
24
|
+
self.q_api_has_many = relations
|
25
25
|
end
|
26
26
|
|
27
27
|
def quick_api_belongs_to(*relations)
|
28
|
-
self.
|
28
|
+
self.q_api_belongs_to = relations
|
29
29
|
end
|
30
30
|
|
31
31
|
def quick_api_has_one(*relations)
|
32
|
-
self.
|
32
|
+
self.q_api_has_one = relations
|
33
33
|
end
|
34
34
|
|
35
35
|
def quick_api_has_and_belongs_to_many(*relations)
|
36
|
-
self.
|
36
|
+
self.q_api_has_and_belongs_to_many = relations
|
37
37
|
end
|
38
38
|
|
39
39
|
def quick_api_embeds_many(*relations)
|
40
|
-
self.
|
40
|
+
self.q_api_embeds_many = relations
|
41
41
|
end
|
42
42
|
|
43
43
|
def quick_api_embedded_in(*relations)
|
44
|
-
self.
|
44
|
+
self.q_api_embedded_in = relations
|
45
45
|
end
|
46
46
|
|
47
47
|
def quick_api_embeds_one(*relations)
|
48
|
-
self.
|
48
|
+
self.q_api_embeds_one = relations
|
49
49
|
end
|
50
50
|
|
51
51
|
# def quick_api_methods(*methods)
|
@@ -58,7 +58,7 @@ module QuickApi
|
|
58
58
|
if options[:fields]
|
59
59
|
api_fields = options[:fields]
|
60
60
|
else
|
61
|
-
api_fields = self.
|
61
|
+
api_fields = self.q_api_attributes.nil? ? [] : self.q_api_attributes
|
62
62
|
end
|
63
63
|
api_fields.each do |api_field|
|
64
64
|
begin
|
@@ -88,13 +88,13 @@ module QuickApi
|
|
88
88
|
# end
|
89
89
|
|
90
90
|
if options[:relations] == true
|
91
|
-
result = api_many_options(result, self.
|
92
|
-
result = api_belongs_or_one_options(result, self.
|
93
|
-
result = api_belongs_or_one_options(result, self.
|
94
|
-
result = api_many_options(result, self.
|
95
|
-
result = api_many_options(result, self.
|
96
|
-
result = api_belongs_or_one_options(result, self.
|
97
|
-
result = api_belongs_or_one_options(result, self.
|
91
|
+
result = api_many_options(result, self.q_api_has_many) if self.q_api_has_many
|
92
|
+
result = api_belongs_or_one_options(result, self.q_api_belongs_to) if self.q_api_belongs_to
|
93
|
+
result = api_belongs_or_one_options(result, self.q_api_has_one) if self.q_api_has_one
|
94
|
+
result = api_many_options(result, self.q_api_has_and_belongs_to_many) if self.q_api_has_and_belongs_to_many
|
95
|
+
result = api_many_options(result, self.q_api_embeds_many) if self.q_api_embeds_many
|
96
|
+
result = api_belongs_or_one_options(result, self.q_api_embedded_in) if self.q_api_embedded_in
|
97
|
+
result = api_belongs_or_one_options(result, self.q_api_embeds_one) if self.q_api_embeds_one
|
98
98
|
end
|
99
99
|
|
100
100
|
result = api_set_options(result, options)
|
data/lib/quick_api/version.rb
CHANGED