Skip to content

Instantly share code, notes, and snippets.

@d1rewolf
Created November 28, 2011 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d1rewolf/1402560 to your computer and use it in GitHub Desktop.
Save d1rewolf/1402560 to your computer and use it in GitHub Desktop.
Pry
From: /home/user/workspace/ruby/project/vendor/plugins/state_machine/lib/state_machine/integrations/active_model.rb @ line 254 in StateMachine::Machine#write:
249: @defaults = {}
250:
251: # Forces the change in state to be recognized regardless of whether the
252: # state value actually changed
253: def write(object, attribute, value)
=>254: binding.pry
255: result = super
256: if attribute == :state && supports_dirty_tracking?(object) && !object.send("#{self.attribute}_changed?")
257: object.send("#{self.attribute}_will_change!")
258: end
259: result
[1] pry(#<StateMachine::Machine>)> value
=> "accounting"
[2] pry(#<StateMachine::Machine>)> class
[2] pry(#<StateMachine::Machine>)*
[2] pry(#<StateMachine::Machine>)* self.class
[2] pry(#<StateMachine::Machine>)* IRB::Abort: abort then interrupt!!
from /home/user/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb.rb:88:in `irb_abort'
[3] pry(#<StateMachine::Machine>)> self.class
=> StateMachine::Machine
[4] pry(#<StateMachine::Machine>)> value
=> "accounting"
[5] pry(#<StateMachine::Machine>)> self.class.parent
=> StateMachine
[6] pry(#<StateMachine::Machine>)> self.class.parent.class
=> Module
[7] pry(#<StateMachine::Machine>)> self.class.parent.class.method(:write)
NameError: undefined method `write' for class `Class'
from (pry):6:in `method'
[8] pry(#<StateMachine::Machine>)> show-method StateMachine::Machine#write --super
Error: The method 'write' is not defined in a superclass of 'StateMachine::Machine'. Type `show-method --help` for help.
(pry) output error: #<NoMethodError: undefined method `message' for true:TrueClass>
[9] pry(#<StateMachine::Machine>)> show-method StateMachine::Machine#write
From: /home/user/workspace/ruby/project/vendor/plugins/state_machine/lib/state_machine/machine.rb @ line 904:
Number of lines: 3
Owner: StateMachine::Machine
Visibility: public
def write(object, attribute, value)
object.send("#{self.attribute(attribute)}=", value)
end
[10] pry(#<StateMachine::Machine>)> show-method StateMachine::Machine#write --super
Error: The method 'write' is not defined in a superclass of 'StateMachine::Machine'. Type `show-method --help` for help.
[11] pry(#<StateMachine::Machine>)> show-method
From: /home/user/workspace/ruby/project/vendor/plugins/state_machine/lib/state_machine/integrations/active_model.rb @ line 253:
Number of lines: 8
Owner: StateMachine::Integrations::ActiveModel
Visibility: public
def write(object, attribute, value)
binding.pry
result = super
if attribute == :state && supports_dirty_tracking?(object) && !object.send("#{self.attribute}_changed?")
object.send("#{self.attribute}_will_change!")
end
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment