Skip to content

Instantly share code, notes, and snippets.

@bltavares
Created January 26, 2012 11:26
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 bltavares/1682339 to your computer and use it in GitHub Desktop.
Save bltavares/1682339 to your computer and use it in GitHub Desktop.
DelegateStuff
#pseudo code
class User < ActiveRecord::Base
named_scope :actives, where(:actived => true)
end
class BrunoUserClass < SomeDelegateClass(User)
def self.actives
super.where(name => "Bruno")
end
def name
super + " is an awesome name"
end
end
first_bruno = BrunoUserClass.actives.first
decorated_bruno = BrunoUserClass.new first_bruno
puts decorated_bruno.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment