Skip to content

Instantly share code, notes, and snippets.

@zakgrant
Created March 10, 2012 15:44
Show Gist options
  • Save zakgrant/2011830 to your computer and use it in GitHub Desktop.
Save zakgrant/2011830 to your computer and use it in GitHub Desktop.
Alias'd Instantiation
class Person
attr_accessor :first_name, :surname
@first_name = 'zak'
@surname = 'grant'
class << self
def new(options={})
Person.new options
end
def method_missing(method, *args, &block)
return super unless new.respond_to? method
new.send method, *args, &block
end
end
def full_name
"#{@first_name} #{@surname}"
end
end
puts "#{Person.full_name}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment