Sha256: 76965e7eecb8fe1bc134a7d8d428bc18d4b8af8441d3581238ce43e94d4e8c4c

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

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

class Card
  module Env
    class << self
      def reset args={}
        @@env = {}
      
        if c = args[:controller]
          self[:controller] = c
          self[:session]    = c.request.session
          self[:params]     = c.request.params
          self[:ip]         = c.request.remote_ip
          self[:ajax]       = c.request.xhr? || c.request.params[:simulate_xhr]
          self[:host]       = Wagn.config.override_host     || c.request.env['HTTP_HOST']
          self[:protocol]   = Wagn.config.override_protocol || c.request.protocol
        
        end
      end
    
      def [] key
        @@env[key.to_sym]
      end
    
      def []= key, value
        @@env[key.to_sym] = value
      end
      

      def params
        self[:params] ||= {}
      end
      
      def session
        self[:session] ||= {}
      end
    
      def ajax?
        self[:ajax]
      end
    
      def method_missing method_id, *args
        case args.length
        when 0 ; self[ method_id ]
        when 1 ; self[ method_id ] = args[0]
        else   ; super
        end
      end
    

    end
  end  
  Env.reset
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wagn-1.14.5 lib/card/env.rb