Skip to content

Instantly share code, notes, and snippets.

@simonista
Last active February 10, 2016 19:54
Show Gist options
  • Select an option

  • Save simonista/ae3dec376a3272c0782b to your computer and use it in GitHub Desktop.

Select an option

Save simonista/ae3dec376a3272c0782b to your computer and use it in GitHub Desktop.

Revisions

  1. simonista revised this gist Feb 10, 2016. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions fixme.rb
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@


    # Current gotcha's:
    # - any result to be cached in the ivar (currently not true for the early return)
    # - if any of the early return stuff, or if the session.key is created, we don't want to run brand_config_for_account(opts)

    def active_brand_config(opts={})
    @active_brand_config_cache ||= {}
  2. simonista revised this gist Feb 10, 2016. 1 changed file with 18 additions and 15 deletions.
    33 changes: 18 additions & 15 deletions fixme.rb
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,19 @@
    def active_brand_config(opts={})
    @active_brand_config_cache ||= {}
    return @active_brand_config_cache[opts] if @active_brand_config_cache.key?(opts)
    @active_brand_config_cache[opts] = begin
    return nil if !use_new_styles? || (@current_user.try(:prefers_high_contrast?) && !opts[:ignore_high_contrast_preference])
    brand_config = if session.key?(:brand_config_md5)
    BrandConfig.where(md5: session[:brand_config_md5]).first
    else
    brand_config_for_account(opts)
    end
    if !brand_config && k12?
    brand_config = BrandConfig.k12_config
    end
    brand_config



    def active_brand_config(opts={})
    @active_brand_config_cache ||= {}
    return @active_brand_config_cache[opts] if @active_brand_config_cache.key?(opts)
    @active_brand_config_cache[opts] = begin
    return nil if !use_new_styles? || (@current_user.try(:prefers_high_contrast?) && !opts[:ignore_high_contrast_preference])
    brand_config = if session.key?(:brand_config_md5)
    BrandConfig.where(md5: session[:brand_config_md5]).first
    else
    brand_config_for_account(opts)
    end
    end
    if !brand_config && k12?
    brand_config = BrandConfig.k12_config
    end
    brand_config
    end
    end
  3. simonista created this gist Feb 10, 2016.
    16 changes: 16 additions & 0 deletions fixme.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    def active_brand_config(opts={})
    @active_brand_config_cache ||= {}
    return @active_brand_config_cache[opts] if @active_brand_config_cache.key?(opts)
    @active_brand_config_cache[opts] = begin
    return nil if !use_new_styles? || (@current_user.try(:prefers_high_contrast?) && !opts[:ignore_high_contrast_preference])
    brand_config = if session.key?(:brand_config_md5)
    BrandConfig.where(md5: session[:brand_config_md5]).first
    else
    brand_config_for_account(opts)
    end
    if !brand_config && k12?
    brand_config = BrandConfig.k12_config
    end
    brand_config
    end
    end