Skip to content

Instantly share code, notes, and snippets.

@svesely
Created September 12, 2011 15:49
Show Gist options
  • Save svesely/1211602 to your computer and use it in GitHub Desktop.
Save svesely/1211602 to your computer and use it in GitHub Desktop.
Collection operations?
# My understanding of classical OOP would suggest that this model is a better model of the business practice:
class Payment
def process
###
end
end
Class PaymentCollection
has_many :payments
def process_all_payments
###
end
end
# However, with many Ruby (read: "Rails") apps, we're encouraged to tie the "multiple instances" operations into the class itself:
class Payment
def self.process_all_payments(ids = [])
###
end
def process
end
end
end
# How does this coincide with the concept of "classical OOP"?
@avdi
Copy link

avdi commented Sep 12, 2011

On line #12, did you mean for that to be a singleton method?

@svesely
Copy link
Author

svesely commented Sep 12, 2011

Nope- I was conflating the two concepts. Updated.

@avdi
Copy link

avdi commented Sep 12, 2011

Thanks for the clarification!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment