Sha256: b8b7acf5d5912451a2534c4fbe9c0b9ed33b4c65e7258ee8c04dab9901148bcd

Contents?: true

Size: 960 Bytes

Versions: 7

Compression:

Stored size: 960 Bytes

Contents

# Wagn::Env can differ for each request; Wagn.config should not

module Wagn::Env
  class << self
    def reset args={}
      @@env = { :main_name => nil }
      
      if c = args[:controller]
        self[:controller] = c
        self[:params] = c.request.params
        
        self[:host]       = Wagn.config.override_host     || c.request.env['HTTP_HOST']
        self[:protocol]   = Wagn.config.override_protocol || c.request.protocol
        
        #hacky - should be in module
        self[:recaptcha_on] = !Account.logged_in? && have_recaptcha_keys?
        self[:recaptcha_count] = 0
      end
    end
    
    def [] key
      @@env[key.to_sym]
    end
    
    def []= key, value
      @@env[key.to_sym] = value
    end

    def params
      self[:params] || {}
    end
    
    private
    
    def have_recaptcha_keys?
      !!( Wagn.config.recaptcha_public_key && Wagn.config.recaptcha_private_key )
    end    
  end  
end

Wagn::Env.reset

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wagn-1.12.13 lib/wagn/env.rb
wagn-1.12.12 lib/wagn/env.rb
wagn-1.12.11 lib/wagn/env.rb
wagn-1.12.10 lib/wagn/env.rb
wagn-1.12.9 lib/wagn/env.rb
wagn-1.12.8 lib/wagn/env.rb
wagn-1.12.7 lib/wagn/env.rb