Class: UserState

Inherits:
Object
  • Object
show all
Defined in:
app/models/user_state.rb

Overview

The State of the User.

When it signs up, it's pending verification. Some features of the system may be limited for verified Users only.

When it clicks on the link in the verification e-mail, it goes to the confirmed state. The use can make full use of the system while in this state.

In case a User is causing problems, it can be transitioned to the blocked state. In that case, the user is inactive.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (String) label

Returns the label that describes the UserState.

Returns:

  • (String)

    the label that describes the UserState.



14
15
16
# File 'app/models/user_state.rb', line 14

def label
  @label
end

Instance Method Details

- (Boolean) block(user)

If the User is in the pending state, transition it to the blocked state.

If the User is in the confirmed state, transition it to the blocked state.

If the User is in the blocked state, do nothing.

Parameters:

  • user (User)

    the user to be transitioned.

Returns:

  • (Boolean)

    whether any transition ocurred.



38
39
# File 'app/models/user_state.rb', line 38

def block user
end

- (Boolean) confirm(user)

If the User is in the pending state, transition it to the confirmed state.

If the User is in the confirmed state, do nothing.

If the User is in the blocked state, fail.

Parameters:

  • user (User)

    the user to be transitioned.

Returns:

  • (Boolean)

    whether any transition ocurred.



25
26
# File 'app/models/user_state.rb', line 25

def confirm user
end

- (Boolean) unblock(user)

If the User is in the pending state, do nothing.

If the User is in the confirmed state, do nothing.

If the User is in the blocked state, transition it to the confirmed state.

Parameters:

  • user (User)

    the user to be transitioned.

Returns:

  • (Boolean)

    whether any transition ocurred.



50
51
# File 'app/models/user_state.rb', line 50

def unblock user
end