Module: Maturate::InstanceMethods

Defined in:
lib/maturate.rb

Instance Method Summary collapse

Instance Method Details

#api_versionObject

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_versionsObject

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_versionObject



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_generationObject

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