Module: Maturate::InstanceMethods
- Defined in:
- lib/maturate.rb
Instance Method Summary collapse
-
#api_version ⇒ Object
The api version of the current request.
-
#api_versions ⇒ Object
Instance-level shortcut for a class-level accessor.
- #current_api_version ⇒ Object
-
#skip_versioned_url_generation ⇒ Object
Don’t add api_version to the default url params.
Instance Method Details
#api_version ⇒ Object
The api version of the current request
186 187 188 189 190 |
# File 'lib/maturate.rb', line 186 def api_version version = params[:api_version] return current_api_version if version == 'current' api_versions.include?(version) ? version : current_api_version end |
#api_versions ⇒ Object
Instance-level shortcut for a class-level accessor
181 182 183 |
# File 'lib/maturate.rb', line 181 def api_versions self.class.api_versions end |
#current_api_version ⇒ Object
206 207 208 |
# File 'lib/maturate.rb', line 206 def current_api_version self.class._current_api_version || api_versions.last end |
#skip_versioned_url_generation ⇒ Object
Don’t add api_version to the default url params. Do this in a before_action call: Example:
class HumansController < ApplicationController
before_action :skip_versioned_url_generation, only: :show
def show
render location: unversioned_human_path(Human.first)
end
end
202 203 204 |
# File 'lib/maturate.rb', line 202 def skip_versioned_url_generation @_skip_versioned_url_generation = true end |