shogun 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shogun/dispatch.rb +9 -1
- data/lib/shogun/presenter.rb +7 -6
- data/lib/shogun/presenters.rb +6 -4
- data/lib/shogun/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: 02e8647eef4b1ea5099c0c31bbb4988ac866b008
|
4
|
+
data.tar.gz: faf525b9463b5ff57a06c4504364de1795755f1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41c57b5eca22864a1cd4e59a746ca454e35dfc5e4c91eeaa6a12465aa796297f3b86b20f613851a1bc15c724d522aab13edb78fa672bb803351fc403ea41db50
|
7
|
+
data.tar.gz: 25bdbf46d916cc873efb2b845230ff25eef377170b24d886dd0167d6d14ee6423322a021fab3476d458931e8510a6d0f96b48747672cd6ad6ac560a00052d397
|
data/lib/shogun/dispatch.rb
CHANGED
@@ -37,7 +37,15 @@ module Shogun
|
|
37
37
|
|
38
38
|
control = route.control.new(payload: payload)
|
39
39
|
|
40
|
-
|
40
|
+
@logger.debug(self.class) do
|
41
|
+
"Request `#{lookup.request}` handled by `#{route.control}`"
|
42
|
+
end
|
43
|
+
|
44
|
+
control.to_a.tap do |response|
|
45
|
+
@logger.debug(self.class) do
|
46
|
+
"Response `#{response[0]}` with `#{response[2]}`"
|
47
|
+
end
|
48
|
+
end
|
41
49
|
end
|
42
50
|
|
43
51
|
def push(route:)
|
data/lib/shogun/presenter.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module Shogun
|
2
2
|
module Presenter
|
3
|
-
def initialize(resource:, meta: {}, links: {}, linked: {})
|
3
|
+
def initialize(resource:, includes: [], meta: {}, links: {}, linked: {})
|
4
4
|
@source = resource
|
5
|
+
@includes = includes
|
5
6
|
@meta = meta
|
6
7
|
@links = links
|
7
8
|
@linked = linked
|
@@ -21,7 +22,7 @@ module Shogun
|
|
21
22
|
|
22
23
|
def links
|
23
24
|
@links.tap do |hash|
|
24
|
-
|
25
|
+
includes.each do |name|
|
25
26
|
case association(name).macro
|
26
27
|
when :has_many
|
27
28
|
hash.store(name, source.public_send(name).pluck(:id))
|
@@ -38,10 +39,6 @@ module Shogun
|
|
38
39
|
ENV["API_HOST"]
|
39
40
|
end
|
40
41
|
|
41
|
-
private def associations
|
42
|
-
self.class.const_get("ASSOCIATIONS")
|
43
|
-
end
|
44
|
-
|
45
42
|
private def namespace
|
46
43
|
self.class.const_get("NAMESPACE")
|
47
44
|
end
|
@@ -53,5 +50,9 @@ module Shogun
|
|
53
50
|
private def source
|
54
51
|
@source
|
55
52
|
end
|
53
|
+
|
54
|
+
private def includes
|
55
|
+
@includes
|
56
|
+
end
|
56
57
|
end
|
57
58
|
end
|
data/lib/shogun/presenters.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
module Shogun
|
2
2
|
class Presenters
|
3
|
-
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
def initialize(resources:, cast:, includes: [], meta: {}, links: {}, linked: {})
|
4
6
|
@sources = resources.map do |resource|
|
5
|
-
cast.new(resource: resource)
|
7
|
+
cast.new(resource: resource, includes: includes)
|
6
8
|
end
|
7
9
|
@meta = meta
|
8
10
|
@links = links
|
9
11
|
@linked = linked
|
10
12
|
end
|
11
13
|
|
12
|
-
def
|
13
|
-
@sources.
|
14
|
+
def each(&block)
|
15
|
+
@sources.each(&block)
|
14
16
|
end
|
15
17
|
|
16
18
|
def meta
|
data/lib/shogun/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shogun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kurtis Rainbolt-Greene
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: adamantium
|