graphiti 1.0.alpha.24 → 1.0.alpha.25

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: 67b89c099870abde2d636eb3808e813b96610f82
4
- data.tar.gz: f8324c6a127cb1fe844b3913ec08ebe8f84da57d
3
+ metadata.gz: 11c4f6ec02d7b26ada772125aa0a6f93adef149c
4
+ data.tar.gz: ff61a24878530f72a9347dee1666e3c00daedb9d
5
5
  SHA512:
6
- metadata.gz: 15474cfc1554159f641a0dff3eded7760cf9c4b0c56f869b2bab9f85006c2e24208206e056614991f0a047779e8ecd772e98d4182ecc4c808e41d1ef4b3e2e68
7
- data.tar.gz: d26dcca3b5eca5158e74b6def93463420ba607552d31e48bfcc546e38dab92880abf13fe04abb6740128a4c918622e801cee5f0562262ece84815678ea36b5fb
6
+ metadata.gz: 9f39008d0879c9cae9fb68f4e259603783d873983cceb93d1fd1dfc424f9a62fdf2ad803b00229ed27fe8986d4eb6ab80ac34a2c23a5a80b730e1b85bc8e6c3f
7
+ data.tar.gz: 95fd32a819cd3f40965c636dc3235c996cce23621d4881aca88f9e083801f52b3473094b637dc241b382a6573dd2ad76e8d5137384a8333c732b7b503c56871b
data/lib/graphiti.rb CHANGED
@@ -130,9 +130,11 @@ module Graphiti
130
130
  # When we add a sideload, we need to do configuration, such as
131
131
  # adding the relationship to the Resource's serializer.
132
132
  # However, the sideload's Resource class may not be loaded yet.
133
- # This is not a problem with Rails autoloading, but is a problem
134
- # outside Rails.
135
- # In these cases, load every Resource class then call Graphiti.setup!
133
+ #
134
+ # This is not a problem when Rails autoloading, but is a problem
135
+ # when *eager* loading, or not using Rails.
136
+ #
137
+ # So, load every Resource class then call Graphiti.setup!
136
138
  def self.setup!
137
139
  resources.each do |r|
138
140
  r.apply_sideloads_to_serializer
@@ -9,6 +9,13 @@ module Graphiti
9
9
  end
10
10
 
11
11
  initializer 'graphiti.init' do
12
+ if ::Rails.application.config.eager_load
13
+ config.after_initialize do |app|
14
+ ::Rails.application.reload_routes!
15
+ Graphiti.setup!
16
+ end
17
+ end
18
+
12
19
  if Mime[:jsonapi].nil? # rails 4
13
20
  Mime::Type.register('application/vnd.api+json', :jsonapi)
14
21
  end
@@ -17,7 +17,7 @@ module Graphiti
17
17
  parent.children[name] = sideload
18
18
  else
19
19
  config[:sideloads][name] = sideload
20
- apply_sideloads_to_serializer if sideload.resource_class_loaded?
20
+ apply_sideloads_to_serializer if rails_autoloading?
21
21
  end
22
22
  sideload
23
23
  end
@@ -104,6 +104,10 @@ module Graphiti
104
104
 
105
105
  memo
106
106
  end
107
+
108
+ def rails_autoloading?
109
+ defined?(::Rails) && !::Rails.application.config.eager_load
110
+ end
107
111
  end
108
112
  end
109
113
  end
@@ -103,7 +103,7 @@ module Graphiti
103
103
  @sideload.link? &&
104
104
  @sideload.children.values.all? { |c| !c.resource.endpoint.nil? }
105
105
  else
106
- @sideload.link? && @sideload.resource.endpoint
106
+ !!(@sideload.link? && @sideload.resource.endpoint)
107
107
  end
108
108
  end
109
109
  end
@@ -1,3 +1,3 @@
1
1
  module Graphiti
2
- VERSION = "1.0.alpha.24"
2
+ VERSION = "1.0.alpha.25"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiti
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.alpha.24
4
+ version: 1.0.alpha.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond