shogun 3.4.0 → 4.0.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/presenter.rb +14 -6
- data/lib/shogun/presenters.rb +10 -1
- 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: 5a13c92ba733fd72e94d508faf1a68b1e422fb63
|
4
|
+
data.tar.gz: 234b2edfa6cd05b942bf473373393e049da94534
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfcd32715980755c6f43700a8dc255b37e47ecd97b6102d12bf56ed368246a9311f8a3024d4f7e733a081a8c5a3eace42a5ff9a5bf86d80cb4127a850678e4e5
|
7
|
+
data.tar.gz: 0ef2da1e448489317249f13d22e6815e58a7d5d97414148b20faeeb6791a6bdcf19b06b9ef3468157065f3de7254d3ce047137a861cb10610b3657ec66ce9d27
|
data/lib/shogun/presenter.rb
CHANGED
@@ -16,12 +16,16 @@ module Shogun
|
|
16
16
|
@meta
|
17
17
|
end
|
18
18
|
|
19
|
-
def linked
|
20
|
-
@linked
|
21
|
-
end
|
22
|
-
|
23
19
|
def links
|
24
20
|
@links.tap do |hash|
|
21
|
+
includes.each do |name|
|
22
|
+
hash.store(name, [host, name, "?#{name}=#{id}"].join("/"))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def linked
|
28
|
+
@linked.tap do |hash|
|
25
29
|
includes.each do |name|
|
26
30
|
case association(name).macro
|
27
31
|
when :has_many
|
@@ -36,7 +40,7 @@ module Shogun
|
|
36
40
|
end
|
37
41
|
|
38
42
|
private def host
|
39
|
-
ENV["
|
43
|
+
ENV["SERVER_HOST"]
|
40
44
|
end
|
41
45
|
|
42
46
|
private def namespace
|
@@ -44,7 +48,11 @@ module Shogun
|
|
44
48
|
end
|
45
49
|
|
46
50
|
private def association(name)
|
47
|
-
|
51
|
+
associations[name.to_sym]
|
52
|
+
end
|
53
|
+
|
54
|
+
private def associations
|
55
|
+
source.class.reflections
|
48
56
|
end
|
49
57
|
|
50
58
|
private def source
|
data/lib/shogun/presenters.rb
CHANGED
@@ -3,6 +3,7 @@ module Shogun
|
|
3
3
|
include Enumerable
|
4
4
|
|
5
5
|
def initialize(resources:, cast:, includes: [], meta: {}, links: {}, linked: {})
|
6
|
+
@cast = @cast
|
6
7
|
@sources = resources.map do |resource|
|
7
8
|
cast.new(resource: resource, includes: includes)
|
8
9
|
end
|
@@ -24,7 +25,15 @@ module Shogun
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def links
|
27
|
-
@links
|
28
|
+
@links.tap do |hash|
|
29
|
+
includes.each do |name|
|
30
|
+
hash.store("#{namespace}.#{name}", [host, name, "{#{namespace}.#{name}}"].join("/"))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private def namespace
|
36
|
+
@cast.const_get("NAMESPACE")
|
28
37
|
end
|
29
38
|
end
|
30
39
|
end
|
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:
|
4
|
+
version: 4.0.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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: adamantium
|