Skip to content

Instantly share code, notes, and snippets.

@adelevie
Created February 12, 2016 20:40
Show Gist options
  • Select an option

  • Save adelevie/7809bb86b8e1e4f761b5 to your computer and use it in GitHub Desktop.

Select an option

Save adelevie/7809bb86b8e1e4f761b5 to your computer and use it in GitHub Desktop.
def complete_and_successful
relation = delivery_deadline_expired(@relation)
relation = delivered(relation)
relation = accepted(relation)
relation = cap_submitted(relation)
relation = paid(relation)
relation
end
@dogweather
Copy link

@krues8dr, you've been doing a lot of javascript or python programming. 😄 In Ruby it'd look like this:

def complete_and_successful
  [:delivery_deadline_expired, :delivered, :accepted, :cap_submitted, :paid].inject(@relation) do |obj, method|
    obj.send(method)
  end
end

@krusynth
Copy link

@dogweather Ugh, you're right. Language switching on a Friday afternoon. :) I definitely agree that the chained version is much nicer!

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