Class: Prosperity::MetricFinder

Inherits:
Struct
  • Object
show all
Defined in:
lib/prosperity/metric_finder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#directoryObject

Returns the value of attribute directory

Returns:

  • (Object)

    the current value of directory



2
3
4
# File 'lib/prosperity/metric_finder.rb', line 2

def directory
  @directory
end

Class Method Details

.allObject



9
10
11
# File 'lib/prosperity/metric_finder.rb', line 9

def self.all
  self.new(File.join(Rails.root, "app/prosperity")).metrics
end

.find_by_name(name) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/prosperity/metric_finder.rb', line 13

def self.find_by_name(name)
  klass = name.constantize

  if klass < Metric
    klass
  else
    nil
  end
end

Instance Method Details

#metricsObject



3
4
5
6
7
# File 'lib/prosperity/metric_finder.rb', line 3

def metrics
  Dir[File.join(directory, "**/*_metric.rb")].map do |metric|
    File.basename(metric, ".rb").camelcase.constantize
  end
end