From 858a30e5716de6201087f2798f6d733cfb9b2fd7 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sat, 10 Mar 2012 17:48:54 -0300 Subject: Refactor http_only, remove reader method [Carlos Antonio da Silva & Santiago Pastorino] --- railties/lib/rails/configuration.rb | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index 46b363c70e..bce696c8f9 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -6,6 +6,20 @@ require 'rails/rack' module Rails module Configuration + module HttpOnly #:nodoc: + def initialize + @http_only = false + end + + def http_only! + @http_only = true + end + + def http_only? + @http_only + end + end + # MiddlewareStackProxy is a proxy for the Rails middleware stack that allows # you to configure middlewares in your application. It works basically as a # command recorder, saving each command to be applied after initialization @@ -44,16 +58,11 @@ module Rails # Cookies, Session and Flash, BestStandardsSupport, and MethodOverride. You # can always add any of them later manually if you want. class MiddlewareStackProxy - attr_reader :http_only - alias :http_only? :http_only + include HttpOnly def initialize + super @operations = [] - @http_only = false - end - - def http_only! - @http_only = true end def insert_before(*args, &block) @@ -90,17 +99,16 @@ module Rails attr_accessor :aliases, :options, :templates, :fallbacks, :colorize_logging attr_reader :hidden_namespaces - attr_reader :http_only - alias :http_only? :http_only + include HttpOnly def initialize + super @aliases = Hash.new { |h,k| h[k] = {} } @options = Hash.new { |h,k| h[k] = {} } @fallbacks = {} @templates = [] @colorize_logging = true @hidden_namespaces = [] - @http_only = false end def initialize_copy(source) @@ -114,10 +122,6 @@ module Rails @hidden_namespaces << namespace end - def http_only! - @http_only = true - end - def method_missing(method, *args) method = method.to_s.sub(/=$/, '').to_sym @@ -138,5 +142,6 @@ module Rails end end end + end end -- cgit v1.2.3