Sha256: d5299fe9f683495a6142088ed9d84140c313547e936c6406988cec7459906035
Contents?: true
Size: 854 Bytes
Versions: 2
Compression:
Stored size: 854 Bytes
Contents
module RocketShorts module Versioning extend ActiveSupport::Concern included do class_attribute :_version_range end module ClassMethods def version(version) version = version..version if version.is_a?(Integer) self._version_range = version before_filter :verify_api_version end end protected def version if !instance_variable_defined?(:@version) @version = begin header = request.headers['Accept'].match(/#{RocketShorts.header_format}(\d+?)/) version = header[1] rescue nil version.present? && Integer(version) rescue ArgumentError nil end end @version end def verify_api_version error! :invalid_version if version.present? && !_version_range.include?(version) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rocket_shorts-0.0.2 | lib/rocket_shorts/controller/versioning.rb |
rocket_shorts-0.0.1 | lib/rocket_shorts/controller/versioning.rb |