-
Notifications
You must be signed in to change notification settings - Fork 92
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
base: master
Are you sure you want to change the base?
Better readme on static / dynamic definitons chapter #52
Conversation
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small typo here
There was a problem hiding this comment.
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
3fae95e
to
b36559d
Compare
# 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} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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). |
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.