Command + Document Responsibility Separation Proposal


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  1. module DocumentFunctions
  2. module InstanceMethods
  3. # returns the word that is currently touched by the cursor
  4. def word_touching_cursor
  5.  
  6. end
  7. end
  8.  
  9. def self.included(receiver)
  10. receiver.send :include, InstanceMethods
  11. end
  12. end
  13.  
  14. module DocumentManipulator
  15.  
  16. module InstanceMethods
  17. def document
  18.  
  19. end
  20.  
  21. # replace a range with the given text.
  22. def replace_range(start_offset, stop_offset, text)
  23.  
  24. end
  25. end
  26.  
  27. def self.included(receiver)
  28. receiver.send :include, InstanceMethods
  29. end
  30.  
  31. end
  32.  
  33. module SelectionManipulator
  34. include DocumentFunctions
  35.  
  36. module InstanceMethods
  37.  
  38. def selection
  39.  
  40. end
  41. end
  42.  
  43. def self.included(receiver)
  44. receiver.send :include, InstanceMethods
  45. end
  46.  
  47. end
  48.  
  49. class FooCommand
  50. include SelectionManipulator
  51.  
  52. def run
  53. (self.methods - Object.new.methods).each do |method|
  54. puts method
  55. end
  56. end
  57. end
  58.  
  59. FooCommand.new.run

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.