{"id":13878957,"url":"https://github.com/state-machines/state_machines-activemodel","last_synced_at":"2025-05-15T09:15:44.546Z","repository":{"id":16530578,"uuid":"19283836","full_name":"state-machines/state_machines-activemodel","owner":"state-machines","description":"StateMachines ActiveModel Integration","archived":false,"fork":false,"pushed_at":"2024-07-31T19:08:03.000Z","size":104,"stargazers_count":33,"open_issues_count":4,"forks_count":33,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-29T12:58:04.267Z","etag":null,"topics":["activemodel","ruby","state-machine"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/state-machines.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-04-29T16:41:17.000Z","updated_at":"2024-07-19T03:06:24.000Z","dependencies_parsed_at":"2024-01-22T17:49:29.546Z","dependency_job_id":"c03db8e3-5751-4ada-b818-204750d817c8","html_url":"https://github.com/state-machines/state_machines-activemodel","commit_stats":{"total_commits":58,"total_committers":16,"mean_commits":3.625,"dds":0.5517241379310345,"last_synced_commit":"3ae127470d420d2afe77eee7026ba4c653358641"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/state-machines%2Fstate_machines-activemodel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/state-machines%2Fstate_machines-activemodel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/state-machines%2Fstate_machines-activemodel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/state-machines%2Fstate_machines-activemodel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/state-machines","download_url":"https://codeload.github.com/state-machines/state_machines-activemodel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226138849,"owners_count":17579496,"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":["activemodel","ruby","state-machine"],"created_at":"2024-08-06T08:02:05.350Z","updated_at":"2025-05-15T09:15:44.539Z","avatar_url":"https://github.com/state-machines.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"![Build Status](https://github.com/state-machines/state_machines-activemodel/actions/workflows/ruby.yml/badge.svg)\n[![Code Climate](https://codeclimate.com/github/state-machines/state_machines-activemodel.svg)](https://codeclimate.com/github/state-machines/state_machines-activemodel)\n\n# StateMachines ActiveModel Integration\n\nThe ActiveModel integration is useful for both standalone usage and for providing\nthe base implementation for ORMs which implement the ActiveModel API.  This\nintegration adds support for validation errors and dirty attribute tracking.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'state_machines-activemodel'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install state_machines-activemodel\n\n## Dependencies\n\nActive Model 7.1+\n\n## Usage\n\n```ruby\n\nclass Vehicle\n  include ActiveModel::Dirty\n  include ActiveModel::Validations\n\n  attr_accessor :state\n  define_attribute_methods [:state]\n\n  state_machine initial: :parked do\n    before_transition parked: any - :parked, do: :put_on_seatbelt\n    after_transition any: :parked do |vehicle, transition|\n      vehicle.seatbelt = 'off'\n    end\n    around_transition :benchmark\n\n    event ignite: do\n      transition parked: :idling\n    end\n\n    state :first_gear, :second_gear do\n      validates :seatbelt_on, presence: true\n    end\n  end\n\n  def put_on_seatbelt\n    ...\n  end\n\n  def benchmark\n    ...\n    yield\n    ...\n  end\nend\n```\n\n## Contributing\n\n1. Fork it ( https://github.com/state-machines/state_machines-activemodel/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstate-machines%2Fstate_machines-activemodel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstate-machines%2Fstate_machines-activemodel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstate-machines%2Fstate_machines-activemodel/lists"}