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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0cba5f44740220ceed421671ca29aaf67451e1c8
4
- data.tar.gz: 94496c87fe09aed639148d73f84ab094abe7db52
3
+ metadata.gz: 02e8647eef4b1ea5099c0c31bbb4988ac866b008
4
+ data.tar.gz: faf525b9463b5ff57a06c4504364de1795755f1a
5
5
  SHA512:
6
- metadata.gz: 4b6a4534a71e86e45934c7f049b3cc8e761061c71b796373d308a5406ea067a9749801e8568ccc9703e5c7e74f16125dcacbc84be7bfd5f7c579d38e5965d5a0
7
- data.tar.gz: fb797d95f7f69233ad534fbb3c09270c01c02b076717b4ba18d8ed818dc14813f3d42b2de6245ccb165fec069f164b2e92ef1d151ccb4ffee768e25b003c5692
6
+ metadata.gz: 41c57b5eca22864a1cd4e59a746ca454e35dfc5e4c91eeaa6a12465aa796297f3b86b20f613851a1bc15c724d522aab13edb78fa672bb803351fc403ea41db50
7
+ data.tar.gz: 25bdbf46d916cc873efb2b845230ff25eef377170b24d886dd0167d6d14ee6423322a021fab3476d458931e8510a6d0f96b48747672cd6ad6ac560a00052d397
@@ -37,7 +37,15 @@ module Shogun
37
37
 
38
38
  control = route.control.new(payload: payload)
39
39
 
40
- control.to_a
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:)
@@ -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
- associations.each do |name|
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
@@ -1,16 +1,18 @@
1
1
  module Shogun
2
2
  class Presenters
3
- def initialize(resources:, cast:, meta: {}, links: {}, linked: {})
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 map(&block)
13
- @sources.map(&block)
14
+ def each(&block)
15
+ @sources.each(&block)
14
16
  end
15
17
 
16
18
  def meta
@@ -1,3 +1,3 @@
1
1
  module Shogun
2
- VERSION = "3.0.0"
2
+ VERSION = "3.1.0"
3
3
  end
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.0.0
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-03 00:00:00.000000000 Z
11
+ date: 2014-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: adamantium