Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better readme on static / dynamic definitons chapter #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ristovskiv
Copy link

The code that was posted before changed the value of the state method in the Vehicle class to the initial one, no matter if it already has one or not.

README.md Outdated
@@ -545,6 +545,10 @@ class Machine
def self.new(object, *args, &block)
machine_class = Class.new
machine = machine_class.state_machine(*args, &block)

# this is the `attribute` which stores the value for state in the class
# exaple for the Vehicle it would be `state` reader

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I will correct it right away

@ristovskiv ristovskiv force-pushed the better_readme_for_dynamic_definition branch from 3fae95e to b36559d Compare January 16, 2017 16:12
# This won't change the value of the `attribute` on the Vehicle class if it already
# has a value assigned to it. Otherwise it will set it to the initial one
state = object.send(attribute)
machine_class.new.tap{|machine| machine.send("#{attribute}=", state) if state}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to complicate the example that much? Why the previous example is not good?

Copy link
Author

@ristovskiv ristovskiv Sep 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I really don't know how I've missed this notification...I'm gonna reply back as soon as I get off from work. My apologies, really sorry.

@evsyukovmv
Copy link

Was useful to fix the problem with activerecord and dynamic state machine class (dynamic state machine class overrides activerecord object state to initial on each initialization).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants