forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharting.rb
38 lines (33 loc) · 867 Bytes
/
charting.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class Charting
class << self
extend Forwardable
delegate [
:backend, # charting backend name; FIXME: remove this method
:render_format,
:format, # format for Ruport renderer
:load_helpers,
:data_ok?,
:sample_chart,
:chart_names_for_select,
:chart_themes_for_select,
:serialized,
:deserialized,
:js_load_statement # javascript statement to reload charts
] => :instance
end
# discovery
#
#
def self.instance
@instance ||= new
end
private
def self.new
self == Charting ? detect_available_plugin.new : super
end
def self.detect_available_plugin
subclasses.select(&:available?).max_by(&:priority)
end
end
# load all plugins
Dir.glob(File.join(File.dirname(__FILE__), "charting/*.rb")).each { |f| require_dependency f }