Class: Rumination::DevUser
- Inherits:
-
Object
- Object
- Rumination::DevUser
- Includes:
- ActiveModel::Model
- Defined in:
- lib/rumination/dev_user.rb
Constant Summary collapse
- CannotBeInitialized =
Class.new(RuntimeError)
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#host ⇒ Object
Returns the value of attribute host.
-
#name ⇒ Object
Returns the value of attribute name.
-
#password ⇒ Object
Returns the value of attribute password.
Instance Method Summary collapse
- #attribute_names ⇒ Object
- #attributes ⇒ Object
-
#initialize(args = {}) ⇒ DevUser
constructor
A new instance of DevUser.
Constructor Details
#initialize(args = {}) ⇒ DevUser
Returns a new instance of DevUser.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rumination/dev_user.rb', line 10 def initialize args={} super self.name ||= ENV["USER"] self.name ||= self.email[/^.*(?=@)/] if self.email.present? raise CannotBeInitialized, "Can't guess dev user name" unless self.name.present? self.password ||= ENV["DEV_PASSWORD"] raise CannotBeInitialized, "Can't guess dev user password" unless self.password.present? self.host ||= ENV["DEV_HOST"] raise CannotBeInitialized, "Can't guess dev user email" unless self.email.present? || self.host.present? self.email ||= [name, host].join("@") end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
8 9 10 |
# File 'lib/rumination/dev_user.rb', line 8 def email @email end |
#host ⇒ Object
Returns the value of attribute host.
8 9 10 |
# File 'lib/rumination/dev_user.rb', line 8 def host @host end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/rumination/dev_user.rb', line 8 def name @name end |
#password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/rumination/dev_user.rb', line 8 def password @password end |
Instance Method Details
#attribute_names ⇒ Object
26 27 28 |
# File 'lib/rumination/dev_user.rb', line 26 def attribute_names %w[name password host email] end |
#attributes ⇒ Object
22 23 24 |
# File 'lib/rumination/dev_user.rb', line 22 def attributes attribute_names.map{|attribute| [attribute, send(attribute)]}.to_h end |