Created
January 26, 2012 11:26
-
-
Save bltavares/1682339 to your computer and use it in GitHub Desktop.
DelegateStuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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