Class: Rack::MiniProfiler::TimerStruct::Base
- Inherits:
-
Object
- Object
- Rack::MiniProfiler::TimerStruct::Base
- Defined in:
- lib/mini_profiler/timer_struct/base.rb
Overview
A base class for timing structures
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, val) ⇒ Object
- #as_json(options = nil) ⇒ Object
- #attributes ⇒ Object
-
#initialize(attrs = {}) ⇒ Base
constructor
A new instance of Base.
- #to_json(*a) ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Base
Returns a new instance of Base.
11 12 13 |
# File 'lib/mini_profiler/timer_struct/base.rb', line 11 def initialize(attrs = {}) @attributes = attrs end |
Instance Method Details
#[](name) ⇒ Object
19 20 21 |
# File 'lib/mini_profiler/timer_struct/base.rb', line 19 def [](name) attributes[name] end |
#[]=(name, val) ⇒ Object
23 24 25 |
# File 'lib/mini_profiler/timer_struct/base.rb', line 23 def []=(name, val) attributes[name] = val end |
#as_json(options = nil) ⇒ Object
33 34 35 |
# File 'lib/mini_profiler/timer_struct/base.rb', line 33 def as_json( = nil) @attributes.as_json() end |
#attributes ⇒ Object
15 16 17 |
# File 'lib/mini_profiler/timer_struct/base.rb', line 15 def attributes @attributes ||= {} end |
#to_json(*a) ⇒ Object
27 28 29 30 31 |
# File 'lib/mini_profiler/timer_struct/base.rb', line 27 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 |