Skip to content

Instantly share code, notes, and snippets.

@bf4
Created August 23, 2012 16:29
Show Gist options
  • Save bf4/3438307 to your computer and use it in GitHub Desktop.
Save bf4/3438307 to your computer and use it in GitHub Desktop.
Ruby Module pattern
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