Created
May 15, 2015 18:12
-
-
Save maccman/14604123e3c5e4451939 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PersonHub | |
module Extensions | |
module Version extend self | |
CURRENT_API_VERSION = '2015-04-30' | |
def registered(app) | |
app.set(:version) do |value| | |
condition { request_api_version >= value } | |
end | |
app.helpers Helpers | |
end | |
module Helpers | |
def request_api_version | |
header_api_version || account_api_version | |
end | |
def header_api_version | |
env['HTTP_API_VERSION'] | |
end | |
def account_api_version | |
if current_account.person_api_version.blank? | |
current_account.update_all(person_api_version: CURRENT_API_VERSION) | |
end | |
current_account.person_api_version | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment