Created
August 23, 2012 16:29
-
-
Save bf4/3438307 to your computer and use it in GitHub Desktop.
Ruby Module pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module NameSpace | |
| module MyClass | |
| def self.included(host_class) | |
| host_class.instance_eval do | |
| has_one :thing | |
| attr_accessible :something | |
| validate :foo | |
| extend ClassMethods | |
| include InstanceMethods | |
| private :something | |
| after_initialize do | |
| puts "hi" | |
| end | |
| end | |
| end | |
| module InstanceMethods | |
| def foo | |
| true | |
| end | |
| end | |
| module ClassMethods | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment