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.
109 110 111 112 113 114 |
# File 'lib/rack/web_profiler/collector.rb', line 109 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.
107 108 109 |
# File 'lib/rack/web_profiler/collector.rb', line 107 def datas @datas end |
Instance Method Details
#show_panel(b = nil) ⇒ Boolean
142 143 144 145 |
# File 'lib/rack/web_profiler/collector.rb', line 142 def show_panel(b = nil) @show_panel = !!b unless b.nil? @show_panel end |
#show_tab(b = nil) ⇒ Boolean
152 153 154 155 |
# File 'lib/rack/web_profiler/collector.rb', line 152 def show_tab(b = nil) @show_tab = !!b unless b.nil? @show_tab end |
#status(v = nil) ⇒ Symbol?
Status.
130 131 132 133 134 135 |
# File 'lib/rack/web_profiler/collector.rb', line 130 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.
120 121 122 123 |
# File 'lib/rack/web_profiler/collector.rb', line 120 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
160 161 162 163 164 165 166 167 |
# File 'lib/rack/web_profiler/collector.rb', line 160 def to_h { datas: @datas, status: @status, show_panel: @show_panel, show_tab: @show_tab, } end |