Class: ScoutRailsProxy::MetricMeta
- Inherits:
-
Object
- Object
- ScoutRailsProxy::MetricMeta
- Defined in:
- lib/scout_rails_proxy/metric_meta.rb
Overview
Contains the meta information associated with a metric. Used to lookup Metrics in to Store’s metric_hash.
Instance Attribute Summary collapse
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#desc ⇒ Object
Returns the value of attribute desc.
-
#extra ⇒ Object
Returns the value of attribute extra.
-
#metric_id ⇒ Object
Returns the value of attribute metric_id.
-
#metric_name ⇒ Object
Returns the value of attribute metric_name.
-
#scope ⇒ Object
Returns the value of attribute scope.
Instance Method Summary collapse
- #==(o) ⇒ Object
- #eql?(o) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(metric_name, options = {}) ⇒ MetricMeta
constructor
A new instance of MetricMeta.
-
#to_json(*a) ⇒ Object
To avoid conflicts with different JSON libaries.
Constructor Details
#initialize(metric_name, options = {}) ⇒ MetricMeta
Returns a new instance of MetricMeta.
3 4 5 6 7 8 9 |
# File 'lib/scout_rails_proxy/metric_meta.rb', line 3 def initialize(metric_name, = {}) @metric_name = metric_name @metric_id = nil @scope = Thread::current[:scout_sub_scope] || Thread::current[:scout_scope_name] @desc = [:desc] @extra = {} end |
Instance Attribute Details
#client_id ⇒ Object
Returns the value of attribute client_id.
12 13 14 |
# File 'lib/scout_rails_proxy/metric_meta.rb', line 12 def client_id @client_id end |
#desc ⇒ Object
Returns the value of attribute desc.
13 14 15 |
# File 'lib/scout_rails_proxy/metric_meta.rb', line 13 def desc @desc end |
#extra ⇒ Object
Returns the value of attribute extra.
13 14 15 |
# File 'lib/scout_rails_proxy/metric_meta.rb', line 13 def extra @extra end |
#metric_id ⇒ Object
Returns the value of attribute metric_id.
10 11 12 |
# File 'lib/scout_rails_proxy/metric_meta.rb', line 10 def metric_id @metric_id end |
#metric_name ⇒ Object
Returns the value of attribute metric_name.
10 11 12 |
# File 'lib/scout_rails_proxy/metric_meta.rb', line 10 def metric_name @metric_name end |
#scope ⇒ Object
Returns the value of attribute scope.
11 12 13 |
# File 'lib/scout_rails_proxy/metric_meta.rb', line 11 def scope @scope end |
Instance Method Details
#==(o) ⇒ Object
20 21 22 |
# File 'lib/scout_rails_proxy/metric_meta.rb', line 20 def ==(o) self.eql?(o) end |
#eql?(o) ⇒ Boolean
31 32 33 |
# File 'lib/scout_rails_proxy/metric_meta.rb', line 31 def eql?(o) self.class == o.class && metric_name.downcase.eql?(o.metric_name.downcase) && scope == o.scope && client_id == o.client_id && desc == o.desc end |
#hash ⇒ Object
24 25 26 27 28 29 |
# File 'lib/scout_rails_proxy/metric_meta.rb', line 24 def hash h = metric_name.downcase.hash h ^= scope.downcase.hash unless scope.nil? h ^= desc.downcase.hash unless desc.nil? h end |
#to_json(*a) ⇒ Object
To avoid conflicts with different JSON libaries
16 17 18 |
# File 'lib/scout_rails_proxy/metric_meta.rb', line 16 def to_json(*a) %Q[{"metric_id":#{metric_id || 'null'},"metric_name":#{metric_name.to_json},"scope":#{scope.to_json || 'null'}}] end |