Skip to content

Instantly share code, notes, and snippets.

@dangalipo
Created March 6, 2014 07:00
Show Gist options
  • Save dangalipo/9383880 to your computer and use it in GitHub Desktop.
Save dangalipo/9383880 to your computer and use it in GitHub Desktop.
module Apibase
class User
def self.find_by_api_token(token)
if token.present?
users.find { |u| u['api_key'] == token }
else
nil
end
end
def self.all
users
end
# not how you do private class methods
private
def users
@@USERS ||= JSON.parse(File.read(ApiBase::Engine.config.users_file)).freeze
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment