Class: Trackets::Params

Inherits:
Object
  • Object
show all
Defined in:
lib/trackets/params.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rack_env, hash = nil) ⇒ Params



6
7
8
9
# File 'lib/trackets/params.rb', line 6

def initialize(rack_env, hash = nil)
  @rack_env = rack_env
  @hash = hash
end

Instance Attribute Details

#rack_envObject (readonly)

Returns the value of attribute rack_env.



4
5
6
# File 'lib/trackets/params.rb', line 4

def rack_env
  @rack_env
end

Instance Method Details

#filteredObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/trackets/params.rb', line 19

def filtered
  hash.inject({}) do |ret, (key, value)|
    ret[key] = if value.kind_of?(Hash)
      self.class.new(nil, value).filtered
    else
      Trackets.configuration.blacklisted_key?(key, rack_env) ? "[FILTERED]" : value
    end

    ret
  end
end

#hashObject



15
16
17
# File 'lib/trackets/params.rb', line 15

def hash
  @hash ||= request.params
end

#requestObject



11
12
13
# File 'lib/trackets/params.rb', line 11

def request
  @request ||= Rack::Request.new(rack_env)
end