We Recommend

Building Websites with TYPO3 Building Websites with TYPO3
Follow a clear path through the power and complexity of TYPO3 to get started, and build your own TYPO3 website This book is a fast paced tutorial to creating a website using TYPO3. If you have never used TYPO3, or even any web content management system before, then you need not look further than this book as it walks you through each step to create your own TYPO3 site.


Posted By

drewr on 03/30/07


Tagged

plugin rails patch aasm


Versions (?)


Add text to AASM states


Published in: Diff 


  1. Index: lib/acts_as_state_machine.rb
  2. ===================================================================
  3. --- lib/acts_as_state_machine.rb (revision 66)
  4. +++ lib/acts_as_state_machine.rb (working copy)
  5. @@ -146,6 +146,10 @@
  6. self.send(self.class.state_column).to_sym
  7. end
  8.  
  9. + def current_state_text
  10. + self.send("#{current_state}_text")
  11. + end
  12. +
  13. # Returns what the next state for a given event would be, as a Ruby symbol.
  14. def next_state_for_event(event)
  15. ns = next_states_for_event(event)
  16. @@ -214,10 +218,12 @@
  17. # state :closed, Proc.new { |o| Mailer.send_notice(o) }
  18. # end
  19. def state(name, opts={})
  20. + text = opts.delete(:text) if opts.is_a?(Hash)
  21. state = SupportingClasses::State.new(name.to_sym, opts)
  22. read_inheritable_attribute(:states)[name.to_sym] = state
  23.  
  24. define_method("#{state.name}?") { current_state == state.name }
  25. + define_method("#{state.name}_text") { text || "give me some :text" }
  26. end
  27.  
  28. # Wraps ActiveRecord::Base.find to conveniently find all records in
  29. @@ -265,4 +271,4 @@
  30. end
  31. end
  32. end
  33. -end
  34. \ No newline at end of file
  35. +end

Report this snippet 

You need to login to post a comment.