lib/grape/path.rb in grape-0.9.0 vs lib/grape/path.rb in grape-0.10.0
- old
+ new
@@ -11,17 +11,21 @@
@namespace = namespace
@settings = settings
end
def mount_path
- split_setting(:mount_path, '/')
+ settings[:mount_path]
end
def root_prefix
split_setting(:root_prefix, '/')
end
+ def uses_specific_format?
+ !!(settings[:format] && settings[:content_types].size == 1)
+ end
+
def uses_path_versioning?
!!(settings[:version] && settings[:version_options][:using] == :path)
end
def has_namespace?
@@ -31,11 +35,13 @@
def has_path?
raw_path && raw_path.to_s =~ /^\S/ && raw_path != '/'
end
def suffix
- if !uses_path_versioning? || (has_namespace? || has_path?)
+ if uses_specific_format?
+ ''
+ elsif !uses_path_versioning? || (has_namespace? || has_path?)
'(.:format)'
else
'(/.:format)'
end
end
@@ -62,9 +68,9 @@
parts.flatten.reject { |part| part == '/' }
end
def split_setting(key, delimiter)
return if settings[key].nil?
- settings[key].to_s.split("/")
+ settings[key].to_s.split('/')
end
end
end