Class: AffiliationState

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

Overview

The state of an Affiliation.

When an Affiliation is created by the Customer, it's in the pending state.

When the counterpart confirms, it goes to the trusted state.

When an Provider reports abuse, it goes to the blocked state.

When an Affiliation is created by the Provider, it's already considered trusted.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (String) label

Returns the label that describes the AffiliationState.

Returns:



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

def label
  @label
end

Instance Method Details

- (Boolean) block(affiliation)

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

If the Affiliation is in the trusted state, transition it to the blocked state.

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

Parameters:

  • affiliation (Affiliation)

    the affiliation to be transitioned.

Returns:

  • (Boolean)

    whether any transition ocurred.



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

def block affiliation
end

- (Boolean) confirm(affiliation)

If the Affiliation is in the pending state, transition it to the trusted state.

If the Affiliation is in the trusted state, do nothing.

If the Affiliation is in the blocked state, fail.

Parameters:

Returns:

  • (Boolean)

    whether any transition ocurred.



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

def confirm affiliation
end

- (Boolean) unblock(affiliation)

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

If the Affiliation is in the trusted state, do nothing.

If the Affiliation is in the blocked state, transition it to the trusted state.

Parameters:

  • affiliation (Affiliation)

    the affiliation to be transitioned.

Returns:

  • (Boolean)

    whether any transition ocurred.



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

def unblock affiliation
end