responders 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +2 -2
- data/lib/action_controller/responder.rb +3 -10
- data/lib/responders.rb +2 -1
- data/lib/responders/http_cache_responder.rb +2 -2
- data/lib/responders/version.rb +1 -1
- data/test/action_controller/respond_with_test.rb +3 -5
- data/test/test_helper.rb +0 -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: 8b652ad426b4ce87cb002a4b5562f79c2335c412
|
4
|
+
data.tar.gz: ee67a5d29f4cd5920a228ccc6229c52bfdddfea8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 102cd8209ca03e4275003de1c82814eec7da60f92f118d7dd38bbaca8ce56a1e1fef7b0278a99cecaf9a3016fc85e4381e1fee440a1ecc376c024924b3b9d2dd
|
7
|
+
data.tar.gz: 6733104f4c7ce9f7250f1ce410562661f16b8d11ce0193c0054264682d4757f4b44d47ce2931df6986d0864b6bc74411388caf7a09c2e5707bf00470f29784bd
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 2.0.1
|
2
|
+
|
3
|
+
* Require "rails/railtie" explicitly before using it
|
4
|
+
* Require "action_controller" explicitly before using it
|
5
|
+
* Remove unecessary and limitting `resourceful?` check that required models to implement `to_#{format}` (such checks are responsibility of the rendering layer)
|
6
|
+
|
1
7
|
## 2.0.0
|
2
8
|
|
3
9
|
* Import `respond_with` and class-level `respond_to` from Rails
|
data/README.md
CHANGED
@@ -60,7 +60,7 @@ You can also have embedded HTML. Just create a `_html` scope.
|
|
60
60
|
|
61
61
|
See also the `namespace_lookup` option to search the full hierarchy of possible keys.
|
62
62
|
|
63
|
-
###
|
63
|
+
### LocationResponder
|
64
64
|
|
65
65
|
This responder allows you to use callable objects as the redirect location.
|
66
66
|
Useful when you want to use the `respond_with` method with
|
@@ -72,7 +72,7 @@ class ThingsController < ApplicationController
|
|
72
72
|
respond_to :html
|
73
73
|
|
74
74
|
def create
|
75
|
-
@thing =
|
75
|
+
@thing = Thing.create(params[:thing])
|
76
76
|
respond_with @thing, location: -> { thing_path(@thing) }
|
77
77
|
end
|
78
78
|
end
|
@@ -187,8 +187,8 @@ module ActionController #:nodoc:
|
|
187
187
|
else
|
188
188
|
display_errors
|
189
189
|
end
|
190
|
-
rescue ActionView::MissingTemplate
|
191
|
-
api_behavior
|
190
|
+
rescue ActionView::MissingTemplate
|
191
|
+
api_behavior
|
192
192
|
end
|
193
193
|
|
194
194
|
protected
|
@@ -205,8 +205,7 @@ module ActionController #:nodoc:
|
|
205
205
|
end
|
206
206
|
|
207
207
|
# This is the common behavior for formats associated with APIs, such as :xml and :json.
|
208
|
-
def api_behavior
|
209
|
-
raise error unless resourceful?
|
208
|
+
def api_behavior
|
210
209
|
raise MissingRenderer.new(format) unless has_renderer?
|
211
210
|
|
212
211
|
if get?
|
@@ -218,12 +217,6 @@ module ActionController #:nodoc:
|
|
218
217
|
end
|
219
218
|
end
|
220
219
|
|
221
|
-
# Checks whether the resource responds to the current format or not.
|
222
|
-
#
|
223
|
-
def resourceful?
|
224
|
-
resource.respond_to?("to_#{format}")
|
225
|
-
end
|
226
|
-
|
227
220
|
# Returns the resource location by retrieving it from the options or
|
228
221
|
# returning the resources array.
|
229
222
|
#
|
data/lib/responders.rb
CHANGED
@@ -34,11 +34,11 @@ module Responders
|
|
34
34
|
|
35
35
|
def do_http_cache?
|
36
36
|
get? && @http_cache != false && ActionController::Base.perform_caching &&
|
37
|
-
persisted? &&
|
37
|
+
persisted? && resource.respond_to?(:updated_at)
|
38
38
|
end
|
39
39
|
|
40
40
|
def persisted?
|
41
41
|
resource.respond_to?(:persisted?) ? resource.persisted? : true
|
42
42
|
end
|
43
43
|
end
|
44
|
-
end
|
44
|
+
end
|
data/lib/responders/version.rb
CHANGED
@@ -4,8 +4,6 @@ class Customer < Struct.new(:name, :id)
|
|
4
4
|
extend ActiveModel::Naming
|
5
5
|
include ActiveModel::Conversion
|
6
6
|
|
7
|
-
undef_method :to_json
|
8
|
-
|
9
7
|
def to_xml(options={})
|
10
8
|
if options[:builder]
|
11
9
|
options[:builder].name name
|
@@ -201,9 +199,9 @@ class RespondWithControllerTest < ActionController::TestCase
|
|
201
199
|
assert_equal "<name>david</name>", @response.body
|
202
200
|
|
203
201
|
@request.accept = "application/json"
|
204
|
-
|
205
|
-
|
206
|
-
|
202
|
+
get :using_resource
|
203
|
+
assert_equal "application/json", @response.content_type
|
204
|
+
assert_equal "{\"name\":\"david\",\"id\":13}", @response.body
|
207
205
|
end
|
208
206
|
|
209
207
|
def test_using_resource_with_js_simply_tries_to_render_the_template
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: responders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Valim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|