class Portable::Data::Provider
Container of data sources that is inputted into a writer alongside a document. It contains all the data sources the writer will use to render a document.
Attributes
data_sources_by_name[R]
Public Class Methods
new(data_sources: [])
click to toggle source
# File lib/portable/data/provider.rb, line 21 def initialize(data_sources: []) sources = Source.array(data_sources) @data_sources_by_name = pivot_by_name(sources) assert_no_duplicate_names(sources) freeze end
Public Instance Methods
data_source(name)
click to toggle source
Fail hard if we cannot identify which data source to use. This should help prevent possible configuration issues (i.e. typos.)
# File lib/portable/data/provider.rb, line 32 def data_source(name) data_sources_by_name[name.to_s] || raise(ArgumentError, "data source: '#{name}' cannot be found.") end