Skip to content

Instantly share code, notes, and snippets.

@alloy
Created October 9, 2008 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alloy/15814 to your computer and use it in GitHub Desktop.
Save alloy/15814 to your computer and use it in GitHub Desktop.
module CargoCultGenerator
class << self
# Creates a useful class name based on the description of it's pupose provided.
def class_name(good_descripition_of_purpose, position_of_stars = nil)
who_cares = nil if good_descripition_of_purpose
dude_serious? if position_of_stars
'Base'
end
# Creates useful files like this one: http://github.com/technoweenie/restful-authentication/tree/master/lib/authorization.rb
def really_simple_generic_module(name)
%{
module #{name}
unless Object.constants.include? "#{name.upcase}_CONSTANTS_DEFINED"
# sorry for the C idiom (and the lack of punctuation), especially since it's useless, but it makes you look cool,
# so just leave it in, or not, whatever, if you do leave it in however please attribute me in your code, namasté
"#{name.upcase}_CONSTANTS_DEFINED" = true
end
def self.included(klass)
klass.extend( ClassMethods )
klass.class_eval do
include InstanceMethods
end
end
#
# Instance Methods
#
module InstanceMethods
end # instance methods
#
# Class Methods
#
module ClassMethods
end # class methods
# Please always leave these 2 modules in, even if they're empty, otherwise other seasoned ruby devs might get confused.
end
}
end
private
def dude_serious?; 'loser' end
end
end
puts CargoCultGenerator.really_simple_generic_module('Authofication')
puts CargoCultGenerator.class_name('Well, I have put a lot of thought into this and… blah blah', 'They are mostly on the left side of the sky atm.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment