Class: Trevl::Renderer
- Inherits:
-
Object
- Object
- Trevl::Renderer
- Defined in:
- lib/trevl/renderer.rb,
lib/trevl/renderer/transform.rb,
lib/trevl/renderer/ref_parser.rb,
lib/trevl/renderer/data_fetcher.rb
Defined Under Namespace
Classes: DataFetcher, RefParser, Transform
Instance Attribute Summary collapse
-
#component ⇒ Object
readonly
Returns the value of attribute component.
-
#data_sources ⇒ Object
readonly
Returns the value of attribute data_sources.
-
#inline_source ⇒ Object
readonly
Returns the value of attribute inline_source.
-
#query_params ⇒ Object
readonly
Returns the value of attribute query_params.
-
#raw_data ⇒ Object
readonly
Returns the value of attribute raw_data.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Class Method Summary collapse
- .coerce_fetch_payload(result) ⇒ Object
- .deep_dig_indifferent(obj, keys) ⇒ Object
-
.parse_trevl_ref(ref) ⇒ Object
Public class methods kept for backward compatibility and testing.
Instance Method Summary collapse
-
#initialize(component_hash, query_params = {}, data_sources: {}, data: nil) ⇒ Renderer
constructor
A new instance of Renderer.
- #render ⇒ Object
Constructor Details
#initialize(component_hash, query_params = {}, data_sources: {}, data: nil) ⇒ Renderer
Returns a new instance of Renderer.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/trevl/renderer.rb', line 11 def initialize(component_hash, query_params = {}, data_sources: {}, data: nil) @component = component_hash @query_params = query_params || {} @data_sources = normalize_data_sources(data_sources) @inline_source = data ? DataSource::Static.new(data: data) : nil @raw_data = {} @warnings = [] @refs = RefParser.new @fetcher = DataFetcher.new @transform = Transform.new(@refs) end |
Instance Attribute Details
#component ⇒ Object (readonly)
Returns the value of attribute component.
9 10 11 |
# File 'lib/trevl/renderer.rb', line 9 def component @component end |
#data_sources ⇒ Object (readonly)
Returns the value of attribute data_sources.
9 10 11 |
# File 'lib/trevl/renderer.rb', line 9 def data_sources @data_sources end |
#inline_source ⇒ Object (readonly)
Returns the value of attribute inline_source.
9 10 11 |
# File 'lib/trevl/renderer.rb', line 9 def inline_source @inline_source end |
#query_params ⇒ Object (readonly)
Returns the value of attribute query_params.
9 10 11 |
# File 'lib/trevl/renderer.rb', line 9 def query_params @query_params end |
#raw_data ⇒ Object (readonly)
Returns the value of attribute raw_data.
9 10 11 |
# File 'lib/trevl/renderer.rb', line 9 def raw_data @raw_data end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
9 10 11 |
# File 'lib/trevl/renderer.rb', line 9 def warnings @warnings end |
Class Method Details
.coerce_fetch_payload(result) ⇒ Object
35 |
# File 'lib/trevl/renderer.rb', line 35 def self.coerce_fetch_payload(result) = DataFetcher.new.coerce_payload(result) |
Instance Method Details
#render ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/trevl/renderer.rb', line 23 def render case component["type"] when "text" then render_text when "filter" then has_api? ? render_filter : nil when "table" then has_api? ? render_table : nil when "score" then has_api? ? render_score : nil when "chart" then has_api? ? render_chart : nil end end |