Class: Rack::MiniProfiler::TimerStruct

Inherits:
Object
  • Object
show all
Defined in:
lib/mini_profiler/timer_struct.rb

Overview

A base class for timing structures

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ TimerStruct

Returns a new instance of TimerStruct.



7
8
9
# File 'lib/mini_profiler/timer_struct.rb', line 7

def initialize(attrs={})
  @attributes = attrs
end

Instance Method Details

#[](name) ⇒ Object



15
16
17
# File 'lib/mini_profiler/timer_struct.rb', line 15

def [](name)
  attributes[name]
end

#[]=(name, val) ⇒ Object



19
20
21
22
# File 'lib/mini_profiler/timer_struct.rb', line 19

def []=(name, val)
  attributes[name] = val
  self
end

#attributesObject



11
12
13
# File 'lib/mini_profiler/timer_struct.rb', line 11

def attributes
  @attributes ||= {}
end

#to_json(*a) ⇒ Object



24
25
26
27
28
# File 'lib/mini_profiler/timer_struct.rb', line 24

def to_json(*a)
  # this does could take in an option hash, but the only interesting there is max_nesting.
  #   if this becomes an option we could increase
  ::JSON.generate( @attributes, :max_nesting => 100 )
end