Class: Rack::WebProfiler::Collector::DataStorage
- Inherits:
-
Object
- Object
- Rack::WebProfiler::Collector::DataStorage
- Defined in:
- lib/rack/web_profiler/collector.rb
Overview
TODO:
do DataStorage compatible with Marshal
DataStorage
Used to store datas who Collector needs.
Instance Attribute Summary collapse
-
#datas ⇒ Object
readonly
Returns the value of attribute datas.
Instance Method Summary collapse
-
#initialize ⇒ DataStorage
constructor
A new instance of DataStorage.
- #show_panel(b = nil) ⇒ Boolean
- #show_tab(b = nil) ⇒ Boolean
-
#status(v = nil) ⇒ Symbol?
Status.
-
#store(k, v) ⇒ Object
Store a value.
-
#to_h ⇒ Hash<Symbol, Object>
Transform DataStorage to an Hash.
Constructor Details
#initialize ⇒ DataStorage
Returns a new instance of DataStorage.
110 111 112 113 114 115 |
# File 'lib/rack/web_profiler/collector.rb', line 110 def initialize @datas = Hash.new @status = nil @show_tab = true @show_panel = true end |
Instance Attribute Details
#datas ⇒ Object (readonly)
Returns the value of attribute datas.
108 109 110 |
# File 'lib/rack/web_profiler/collector.rb', line 108 def datas @datas end |
Instance Method Details
#show_panel(b = nil) ⇒ Boolean
143 144 145 146 |
# File 'lib/rack/web_profiler/collector.rb', line 143 def show_panel(b = nil) @show_panel = !!b unless b.nil? @show_panel end |
#show_tab(b = nil) ⇒ Boolean
153 154 155 156 |
# File 'lib/rack/web_profiler/collector.rb', line 153 def show_tab(b = nil) @show_tab = !!b unless b.nil? @show_tab end |
#status(v = nil) ⇒ Symbol?
Status.
131 132 133 134 135 136 |
# File 'lib/rack/web_profiler/collector.rb', line 131 def status(v = nil) # @todo check status? # raise Exception, "" unless [:success, :warning, :danger].include?(v) @status = v.to_sym unless v.nil? @status end |
#store(k, v) ⇒ Object
Store a value.
121 122 123 124 |
# File 'lib/rack/web_profiler/collector.rb', line 121 def store(k, v) # @todo check data format (must be compatible with Marshal) @datas[k.to_sym] = v end |
#to_h ⇒ Hash<Symbol, Object>
Transform DataStorage to an Hash
161 162 163 164 165 166 167 168 |
# File 'lib/rack/web_profiler/collector.rb', line 161 def to_h { datas: @datas, status: @status, show_panel: @show_panel, show_tab: @show_tab, } end |