Created
March 6, 2014 07:00
-
-
Save dangalipo/9383880 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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