Module: Pushover::User
Overview
The user module, saves any user information provided.
Defined Under Namespace
Classes: User
Instance Method Summary collapse
-
#add(token, name) ⇒ Boolean
Add an application to the config file and save it.
-
#current_user ⇒ Object
Return the current user selected, or the first one saved.
-
#current_user? ⇒ Boolean
Will return true if it can find a user either via the cli or save file.
-
#find(word) ⇒ String
Find the apikey in the applications, or pass on the word to try direct access.
Instance Method Details
#add(token, name) ⇒ Boolean
Add an application to the config file and save it.
36 37 38 39 |
# File 'lib/pushover/user.rb', line 36 def add(token, name) User.new token, name Pushover::Config.save! end |
#current_user ⇒ Object
Return the current user selected, or the first one saved.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/pushover/user.rb', line 42 def current_user return @current_user if @current_user # did something get supplied on the cli? try to find it. if Options[:user] @current_user = Pushover::User.find Options[:user] end # no? do we have anything we can return? if !@current_user @current_user = Config[:users].first end @current_user end |
#current_user? ⇒ Boolean
Will return true if it can find a user either via the cli or save file.
58 59 60 61 |
# File 'lib/pushover/user.rb', line 58 def current_user? return true if current_user return nil end |