Skip to content

Commit aea29fd

Browse files
committed
define #content_type instead of ambiguous #content_types
1 parent aec9444 commit aea29fd

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

README.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ By default, Grape supports _XML_, _JSON_, _Atom_, _RSS_, and _text_ content-type
215215

216216
```ruby
217217
class Twitter::API < Grape::API
218-
content_types :xls => "application/vnd.ms-excel"
218+
content_type :xls, "application/vnd.ms-excel"
219219
end
220220
```
221221

lib/grape/api.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ def error_format(new_format = nil)
123123
end
124124

125125
# Specify additional content-types, e.g.:
126-
# content_types :xls => 'application/vnd.ms-excel'
127-
def content_types(map = {})
128-
map.any? ? set(:content_types, map) : settings[:content_types]
126+
# content_type :xls, 'application/vnd.ms-excel'
127+
def content_type(key, val)
128+
settings.imbue(:content_types, key.to_sym => val)
129129
end
130130

131131
# Specify the default status code for errors.

spec/grape/api_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,9 +679,9 @@ def hello
679679
end
680680
end
681681

682-
describe ".content_types" do
682+
describe ".content_type" do
683683
it "sets additional content-type" do
684-
subject.content_types :xls => "application/vnd.ms-excel"
684+
subject.content_type :xls, "application/vnd.ms-excel"
685685
subject.get(:hello) do
686686
"some binary content"
687687
end

0 commit comments

Comments
 (0)