Skip to content

Instantly share code, notes, and snippets.

@maccman
Created May 15, 2015 18:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maccman/14604123e3c5e4451939 to your computer and use it in GitHub Desktop.
Save maccman/14604123e3c5e4451939 to your computer and use it in GitHub Desktop.
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