Skip to content

Instantly share code, notes, and snippets.

@reinh
Created September 3, 2008 20:51
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 reinh/8668 to your computer and use it in GitHub Desktop.
Save reinh/8668 to your computer and use it in GitHub Desktop.
class Organization
def inspect
"An Organization for #@param"
end
def initialize(param)
@param = param
end
def self.find(param)
new(param)
end
end
module StupidDelegationTricks
def convert_to(model)
model.find(self.to_param)
end
end
class String
include StupidDelegationTricks
alias :to_param :to_i
end
"1".convert_to(Organization) # => An Organization for 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment