Hey ianmusc - You might try Cygwin to get you started. Hope that helps.
Really nice approach. You can clean up User#price if you do something like this:
class NoSubscription
def charge
end
def price
end
end
class User
include ActiveModel::Model
attr_accessor :credit_card, :subscription
def subscription
@subscription || NoSubscription.new
end
def charge
subscription.charge(credit_card)
end
def price
subscription.price
end
end
However, I would be careful adding wrapper methods like User#charge and User#price because this tends to lead to God models, especially when working with classes like User, Order, etc.
In general though, your suggestion prevents nil checks and removes conditionals, and that's an excellent improvement!
Cool. I posted a tip similar to this in the past, with some nice suggestions by other devs: https://coderwall.com/p/o5qijw.
@carwin - Interesting. I think @mislav just posted about that at https://coderwall.com/p/uo_big. Nice tip!
Really nice work. Would you mind elaborating on why you check for 'seconds < 45' as opposed to 60?
@tdl - Agreed. I didn't know about the -c
option for the uniq
command, so thanks for sharing that!
You need bigger speakers! ;-)
@slothbear - Good suggestion, as I didn't notice that some tasks were missing. Unfortunately, that didn't work on my system, though (OS X):
☺ rake -T -A db
invalid option: -A
chip@macbook ~/code/project 1.9.3-p194 [master]
☹ rake -V
rake, version 0.9.2.2
Very nice!
I ran into this before and it took me an embarrassingly long time to figure out. This is really helpful. Nice post!
@larrywilliamson - thanks for the suggestion, since others might run into the same issue. Here's more info in case anyone is interested:
http://stackoverflow.com/questions/28881/why-doesnt-sort-sort-the-same-on-every-machine
@orangetux, Thanks! You might want to check out Drew Neil's project: https://github.com/nelstrom/vimprint
I couldn't have said it better. Great stuff, Chris!
The site is now located at http://unixcasts.com.