{"id":21597267,"url":"https://github.com/spheresoftware/state_machine_ext","last_synced_at":"2025-03-18T11:22:08.333Z","repository":{"id":1204854,"uuid":"1114640","full_name":"SphereSoftware/state_machine_ext","owner":"SphereSoftware","description":"state_machine extensions (state groups, find transitions)","archived":false,"fork":false,"pushed_at":"2011-02-11T08:54:40.000Z","size":91,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-04T07:16:50.777Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SphereSoftware.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-11-26T13:45:32.000Z","updated_at":"2018-09-06T18:39:33.000Z","dependencies_parsed_at":"2022-08-16T12:35:15.377Z","dependency_job_id":null,"html_url":"https://github.com/SphereSoftware/state_machine_ext","commit_stats":null,"previous_names":["sphereconsultinginc/state_machine_ext"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SphereSoftware%2Fstate_machine_ext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SphereSoftware%2Fstate_machine_ext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SphereSoftware%2Fstate_machine_ext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SphereSoftware%2Fstate_machine_ext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SphereSoftware","download_url":"https://codeload.github.com/SphereSoftware/state_machine_ext/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244208607,"owners_count":20416110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T18:08:35.370Z","updated_at":"2025-03-18T11:22:08.294Z","avatar_url":"https://github.com/SphereSoftware.png","language":"Ruby","readme":"= state_machine extensions\nstate_machine_ext is an extension of the state_machine[https://github.com/pluginaweek/state_machine] gem.\n\n== Install\n  gem install state_machine_ext\n\n== Usage\nThis gem adds state groups functionality and method to find all possible transitions from a state.\nBelow is an example of the features offered:\n\n=== Class definition\n\n  class Order\n    state_machine :initial =\u003e :not_selected do\n      event :choose do\n        transition :not_selected =\u003e :selected\n      end\n      event :add_to_basket do\n        transition :selected =\u003e :in_basket\n      end\n      event :pay do\n        transition :in_basket =\u003e :paid\n      end\n      event :to_send do\n        transition :paid =\u003e :sent\n      end\n\n      #initialize groups of the states\n      group :not_paid do\n        state :not_selected\n        state :selected\n        state :in_basket\n      end\n      group :in_progress do\n        state :paid, :sent\n      end\n    end\n  end\n\n=== Using extensions\n\n  order = Order.new\n  # returns the array of all the states which we can reach from the current one\n  order.state_all_transitions                #=\u003e [:sent, :paid, :in_basket, :selected]\n  # same for the particular state\n  order.state_all_transitions(:in_basket)    #=\u003e [:sent, :paid]\n  # check whether a group includes some state\n  order.group(:not_paid).include?(:selected) #=\u003e true\n  # find groups to which belongs a state\n  order.find_group(:paid)                    #=\u003e [:in_progress]\n\n\n== Credits\n\n=== Project Team\n* Sphere Consulting Inc Development Team\n\nCopyright (c) 2010 {Sphere Consulting Inc.}[http://www.sphereinc.com], released under the MIT license (see LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspheresoftware%2Fstate_machine_ext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspheresoftware%2Fstate_machine_ext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspheresoftware%2Fstate_machine_ext/lists"}