Guest User

Untitled

a guest
May 11th, 2012
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. module MyModule
  2. module ClassMethods
  3. def modularize(opts = {})
  4. @opts = {:foo => "bar"}.merge opts #set defaults
  5. attr_reader :opts
  6. end
  7. end
  8.  
  9. module InstanceMethods
  10. def opts
  11. self.class.opts
  12. end
  13. end
  14. end
  15.  
  16. class MyClass
  17. extend MyModule::ClassMethods
  18. include MyModule::InstanceMethods
  19.  
  20. modularize :foo => "jitsu"
  21.  
  22. end
  23.  
  24. MyClass.new.opts
Advertisement
Add Comment
Please, Sign In to add comment