Ruby/Rails Features and Patterns

Flashcard 3 of 6

Can you name this "Gang of Four" design pattern?

class TrailWithProgress < SimpleDelegator
  def initialize(trail)
    super
    @trail = trail
  end

  def incomplete?
    unstarted? || in_progress?
  end

  private

  def unstarted?
    # ...
  end

  def in_progress?
    # ...
  end
 end

That's a decorator, yo!

Click here to read more about decorators.

Here's a real-live decorator in the Upcase codebase

And here's how we tested that decorator

(By the way, if those links don't work, make sure to visit https://upcase.com/repositories to get access to the Upcase GitHub repo.)

Return to Flashcard Results