lib/grape/dsl/inside_route.rb in grape-0.14.0 vs lib/grape/dsl/inside_route.rb in grape-0.15.0
- old
+ new
@@ -1,12 +1,14 @@
require 'active_support/concern'
+require 'grape/dsl/headers'
module Grape
module DSL
module InsideRoute
extend ActiveSupport::Concern
include Grape::DSL::Settings
+ include Grape::DSL::Headers
# Denotes a situation where a DSL method has been invoked in a
# filter which it should not yet be available in
class MethodNotYetAvailable < StandardError; end
@@ -136,20 +138,10 @@
else
fail ArgumentError, 'Status code must be Fixnum or Symbol.'
end
end
- # Set an individual header or retrieve
- # all headers that have been set.
- def header(key = nil, val = nil)
- if key
- val ? @header[key.to_s] = val : @header.delete(key.to_s)
- else
- @header
- end
- end
-
# Set response content-type
def content_type(val = nil)
if val
header(Grape::Http::Headers::CONTENT_TYPE, val)
else
@@ -301,10 +293,10 @@
else
object.respond_to?(:first) ? object.first.class : object.class
end
object_class.ancestors.each do |potential|
- entity_class ||= (Grape::DSL::Configuration.stacked_hash_to_hash(namespace_stackable(:representations)) || {})[potential]
+ entity_class ||= (namespace_stackable_with_hash(:representations) || {})[potential]
end
entity_class ||= object_class.const_get(:Entity) if object_class.const_defined?(:Entity) && object_class.const_get(:Entity).respond_to?(:represent)
end