Class: Scout::MetricCalculation
- Inherits:
-
Object
- Object
- Scout::MetricCalculation
- Defined in:
- lib/scout_api/metric_calculation.rb
Instance Attribute Summary collapse
-
#metric_name ⇒ Object
Returns the value of attribute metric_name.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#find_target ⇒ Object
:nodoc:.
-
#initialize(owner, function) ⇒ MetricCalculation
constructor
:nodoc:.
-
#load_target ⇒ Object
:nodoc:.
- #to_array ⇒ Object (also: #to_a)
- #to_sparkline(opts = {}) ⇒ Object
Constructor Details
#initialize(owner, function) ⇒ MetricCalculation
:nodoc:
5 6 7 8 9 |
# File 'lib/scout_api/metric_calculation.rb', line 5 def initialize(owner,function) #:nodoc: @owner = owner @function = function @options = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object (private)
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/scout_api/metric_calculation.rb', line 47 def method_missing(method, *args) if load_target unless @target.respond_to?(method) = "undefined method `#{method.to_s}' for \"#{@target}\":#{@target.class.to_s}" raise NoMethodError, end if block_given? @target.send(method, *args) { |*block_args| yield(*block_args) } else @target.send(method, *args) end end end |
Instance Attribute Details
#metric_name ⇒ Object
Returns the value of attribute metric_name.
3 4 5 |
# File 'lib/scout_api/metric_calculation.rb', line 3 def metric_name @metric_name end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/scout_api/metric_calculation.rb', line 3 def @options end |
Instance Method Details
#find_target ⇒ Object
:nodoc:
30 31 32 33 34 35 |
# File 'lib/scout_api/metric_calculation.rb', line 30 def find_target #:nodoc: .merge!(owner_key_value) Scout::Metric.calculate( @function,metric_name, ) end |
#load_target ⇒ Object
:nodoc:
26 27 28 |
# File 'lib/scout_api/metric_calculation.rb', line 26 def load_target #:nodoc: @target = find_target end |
#to_array ⇒ Object Also known as: to_a
18 19 20 21 22 23 |
# File 'lib/scout_api/metric_calculation.rb', line 18 def to_array .merge!(owner_key_value) Scout::Metric.to_array( @function,metric_name, ) end |
#to_sparkline(opts = {}) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/scout_api/metric_calculation.rb', line 11 def to_sparkline(opts = {}) .merge!(opts).merge!(owner_key_value) Scout::Metric.to_sparkline( @function,metric_name, ) end |