Class: Amp::Servers::User
Overview
User
A single user within an Amp’s server system. Just a simple struct - though they do offer a convenient constructor, taking a hash.
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
-
.from_hash(input = {}) ⇒ Object
Extra constructor - takes a hash to create a new User, instead of the Struct class’s ordered parameters for its constructor.
-
.public_user ⇒ User
Generates a public user - i.e., somebody who has been granted no explicit rights.
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password
8 9 10 |
# File 'lib/amp/server/amp_user.rb', line 8 def password @password end |
#username ⇒ Object
Returns the value of attribute username
8 9 10 |
# File 'lib/amp/server/amp_user.rb', line 8 def username @username end |
Class Method Details
.from_hash(input = {}) ⇒ Object
Extra constructor - takes a hash to create a new User, instead of the Struct class’s ordered parameters for its constructor.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/amp/server/amp_user.rb', line 28 def self.from_hash(input={}) # input checking unless input[:password] raise "User must have a password attribute" end # public is reserved as the username of the public user if input[:username].to_s == 'public' raise "User cannot have username 'public' -- reserved by Amp system" end new input[:username], input[:password] end |
.public_user ⇒ User
Generates a public user - i.e., somebody who has been granted no explicit rights.
13 14 15 |
# File 'lib/amp/server/amp_user.rb', line 13 def self.public_user @@public_user ||= new('public', "") end |