Class: LoginPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/glimmer-dsl-opal/samples/elaborate/login.rb

Overview

Copyright © 2020-2022 Andy Maleh

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLoginPresenter

Returns a new instance of LoginPresenter.


28
29
30
31
32
# File 'lib/glimmer-dsl-opal/samples/elaborate/login.rb', line 28

def initialize
  @user_name = ""
  @password = ""
  @status = "Logged Out"
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.


25
26
27
# File 'lib/glimmer-dsl-opal/samples/elaborate/login.rb', line 25

def password
  @password
end

#statusObject

Returns the value of attribute status.


26
27
28
# File 'lib/glimmer-dsl-opal/samples/elaborate/login.rb', line 26

def status
  @status
end

#user_nameObject

Returns the value of attribute user_name.


24
25
26
# File 'lib/glimmer-dsl-opal/samples/elaborate/login.rb', line 24

def user_name
  @user_name
end

Instance Method Details

#logged_in?Boolean

Returns:

  • (Boolean)

42
43
44
# File 'lib/glimmer-dsl-opal/samples/elaborate/login.rb', line 42

def logged_in?
  self.status == "Logged In"
end

#logged_out?Boolean

Returns:

  • (Boolean)

46
47
48
# File 'lib/glimmer-dsl-opal/samples/elaborate/login.rb', line 46

def logged_out?
  !self.logged_in?
end

#login!Object


50
51
52
53
# File 'lib/glimmer-dsl-opal/samples/elaborate/login.rb', line 50

def login!
  return unless valid?
  self.status = "Logged In"
end

#logout!Object


55
56
57
58
59
# File 'lib/glimmer-dsl-opal/samples/elaborate/login.rb', line 55

def logout!
  self.user_name = ""
  self.password = ""
  self.status = "Logged Out"
end

#valid?Boolean

Returns:

  • (Boolean)

38
39
40
# File 'lib/glimmer-dsl-opal/samples/elaborate/login.rb', line 38

def valid?
  !@user_name.to_s.strip.empty? && !@password.to_s.strip.empty?
end