rooftop-rails 0.0.6 → 0.0.6.3

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: d686ac1326055010ea5a1026d27d6d1b5fa7cfda
4
- data.tar.gz: 62ddec40b4f47c843bc01976efa2dc28a0fa782c
3
+ metadata.gz: 0f1c6a9de292c6a1c912e3ace8972d1891c60f99
4
+ data.tar.gz: e6f4a3e07a5bcb4a224560fe075c582abd132005
5
5
  SHA512:
6
- metadata.gz: 767379cba619e6a39b40c158043328f057119fe595ff215268ef92aace444541be2621197493f5946734d8c4508c5d6a75991ed95b3f06c47dd6eb5731cf7f23
7
- data.tar.gz: 03298dae9b28386035440e077b6a07ed222b3b42a0eadcdee48eff2865d0b1a2eecb8997062fbc320a4505e1250d765dac5f47d7dd0efc6519121c6904211082
6
+ metadata.gz: fb8d2808557ca520a98a96128f52cb4d67cbbd06cea0ebd5cd72167da6d682e4fb0e249ace5cb4221d23b95bebb540a4ee0fe7d1b1bd3c77f019749c7f35c02e
7
+ data.tar.gz: 13955771a1fdd231223611d71f223427020e5a69cb345247d57480c8558e32847187a3b203e4b4ee0f24794e84258fb3a13fd79bfb562a70bf4c2e7d03cc82dc
@@ -4,11 +4,7 @@ module Rooftop
4
4
  def self.expire(payload)
5
5
  begin
6
6
  content_type = payload[:type].to_sym
7
- if Rooftop.configuration.post_type_mapping[content_type].present?
8
- klass = Rooftop.configuration.post_type_mapping[content_type]
9
- else
10
- klass = content_type.to_s.classify.constantize
11
- end
7
+ klass = Rooftop::Rails::PostTypeResolver.new(content_type).resolve
12
8
  klass.send(:expire_cache_for, payload[:id])
13
9
  rescue => e
14
10
  raise Rooftop::Rails::UnknownObjectForExpiry, e
@@ -0,0 +1,27 @@
1
+ module Rooftop
2
+ module Rails
3
+ # A class to generate a proper rails route for Rooftop resources.
4
+ #
5
+ # You can configure a custom route in Rooftop::Rails::Configuration.resource_route_map. If you don't,
6
+ # this class will introspect the Rails routes to try and guess. Otherwise it'll return nothing.
7
+ class PostTypeResolver
8
+ # Create the route resolver, with a type (post, page, whatever) and an optional ID
9
+ attr_accessor :type
10
+ def initialize(type)
11
+ @type = type.to_sym
12
+ end
13
+
14
+ def resolve()
15
+ begin
16
+ if Rooftop.configuration.post_type_mapping[@type].present?
17
+ Rooftop.configuration.post_type_mapping[@type]
18
+ else
19
+ @type.to_s.classify.constantize
20
+ end
21
+ rescue
22
+ nil
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,5 +1,5 @@
1
1
  module Rooftop
2
2
  module Rails
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.6.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rooftop-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Error Studio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-01 00:00:00.000000000 Z
11
+ date: 2016-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: require_all
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: rooftop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '='
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 0.0.7.4
61
+ version: 0.0.7
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '='
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: 0.0.7.4
68
+ version: 0.0.7
69
69
  description: This gem provides utility methods and a mountable engine for Rails applications
70
70
  using the Rooftop gem
71
71
  email:
@@ -89,6 +89,7 @@ files:
89
89
  - lib/rooftop/rails/development_constraint.rb
90
90
  - lib/rooftop/rails/engine.rb
91
91
  - lib/rooftop/rails/errors.rb
92
+ - lib/rooftop/rails/post_type_resolver.rb
92
93
  - lib/rooftop/rails/preview.rb
93
94
  - lib/rooftop/rails/route_resolver.rb
94
95
  - lib/rooftop/rails/version.rb