Skip to content

Instantly share code, notes, and snippets.

@dt1973
Created April 4, 2015 14:44
Show Gist options
  • Save dt1973/965851fab41f3ae8d8b1 to your computer and use it in GitHub Desktop.
Save dt1973/965851fab41f3ae8d8b1 to your computer and use it in GitHub Desktop.

What makes this an infinite loop?

class Photo < ActiveRecord::Base
  attr_accessor :applicable_styles

  before_post_process :setup_styles

  def applicable_styles
    @applicable_styles || setup_styles
  end

  def setup_styles
    @applicable_styles ||= {}

    if is_animated_gif?
      ...
    end

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