Extract method to build a data source
This commit is contained in:
@@ -26,19 +26,17 @@ module Ahoy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.active_events_data_points
|
def self.active_events_data_points
|
||||||
ds = Ahoy::DataSource.new
|
Ahoy::DataSource.build do |data_source|
|
||||||
|
active_event_names.map { |event_name| new(event_name) }.each do |chart|
|
||||||
active_event_names.map { |event_name| new(event_name) }.each do |chart|
|
data_source.add chart.title, chart.data
|
||||||
ds.add chart.title, chart.data
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ds.build
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def data_points
|
def data_points
|
||||||
ds = Ahoy::DataSource.new
|
Ahoy::DataSource.build do |data_source|
|
||||||
ds.add title, data
|
data_source.add title, data
|
||||||
ds.build
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def title
|
def title
|
||||||
|
|||||||
@@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
module Ahoy
|
module Ahoy
|
||||||
class DataSource
|
class DataSource
|
||||||
|
def self.build(&block)
|
||||||
|
new.tap { |data_source| block.call(data_source) }.build
|
||||||
|
end
|
||||||
|
|
||||||
# Adds a collection with the datasource
|
# Adds a collection with the datasource
|
||||||
# Name is the name of the collection and will be showed in the
|
# Name is the name of the collection and will be showed in the
|
||||||
# chart
|
# chart
|
||||||
|
|||||||
Reference in New Issue
Block a user