state_machine

https://github.com/pluginaweek/state_machine

Ruby

Adds support for creating state machines for attributes on any Ruby class

StateMachine::MachineCollection#initialize_states

Initializes the state of each machine in the given object.  This can allow
states to be initialized in two groups: static and dynamic.  For example:

  machines.initialize_states(object) do
    # After static state initialization, before dynamic state initialization
  end

If no block is provided, then all states will still be initialized.

Valid configuration options:
* <tt>:static</tt> - Whether to initialize static states.  If set to
  :force, the state will be initialized regardless of its current value.
  Default is :force.
* <tt>:dynamic</tt> - Whether to initialize dynamic states.  If set to
  :force, the state will be initialized regardless of its current value.
  Default is true.
* <tt>:to</tt> - A hash to write the initialized state to instead of
  writing to the object.  Default is to write directly to the object.

Source | Google | Stack overflow

Edit

git clone [email protected]:pluginaweek/state_machine.git

cd state_machine

open lib/state_machine/machine_collection.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-StateMachine--MachineCollection-initialize_states-for-pr


# Commit to git

git add lib/state_machine/machine_collection.rbgit commit -m "better docs for StateMachine::MachineCollection#initialize_states"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-StateMachine--MachineCollection-initialize_states-for-pr

hub pull-request


# Celebrate!