Module: StateGate::Builder::StateMethods
- Included in:
- StateGate::Builder
- Defined in:
- lib/state_gate/builder/state_methods.rb
Overview
Description
Multiple private methods enabling StateGate::Builder to generate state functionality.
-
query the class for all state:
Klass.statuses #=> [:pending, :active, :archived]
-
query the class for the human names of all state:
Klass.human_statuses #=> ['Pending Activation', 'Active', 'Archived']
-
query the class for an Array of human names/state names for use in a select form:
Klass.statuses_for_select #=> [['Pending Activation', 'pending'],["Active', 'active'], ['Archived','archived']]
-
list all attribute states:
.status_states #=> [:pending, :active, :archived]
-
list all human names for the attribute states:
.status_human_names #=> ['Pending Activation', 'Active', 'Archived']
-
list the human name for the attribute state:
.human_status #=> 'Pending Activation'
-
is a particular state set:
.pending? #=> false .active? #=> true .archived? #=> false
-
is a particular state not set:
.not_pending? #=> true .not_active? #=> false .not_archived? #=> true
-
list the allowed transitions for the current state.
.status_transitions #=> [:suspended, :archived]