Class: Mxrb::Compiler::WebListDataSource
- Inherits:
-
Object
- Object
- Mxrb::Compiler::WebListDataSource
- Includes:
- ModelValues
- Defined in:
- lib/mxrb/compiler/web_list_data_source.rb
Overview
Resolves React list data sources and safely lowers unusable simple connector reads to XPath. rubocop:disable Metrics
Instance Attribute Summary collapse
-
#association_path ⇒ Object
readonly
Returns the value of attribute association_path.
-
#entity ⇒ Object
readonly
Returns the value of attribute entity.
-
#microflow_name ⇒ Object
readonly
Returns the value of attribute microflow_name.
-
#nanoflow_name ⇒ Object
readonly
Returns the value of attribute nanoflow_name.
-
#xpath_constraint ⇒ Object
readonly
Returns the value of attribute xpath_constraint.
Instance Method Summary collapse
- #association? ⇒ Boolean
- #flow_name(source, key) ⇒ Object
-
#initialize(source, widget) ⇒ WebListDataSource
constructor
A new instance of WebListDataSource.
- #microflow? ⇒ Boolean
- #nanoflow? ⇒ Boolean
- #resolve_entity ⇒ Object
- #resolve_flows ⇒ Object
- #resolve_sources ⇒ Object
- #supported? ⇒ Boolean
- #xpath? ⇒ Boolean
Constructor Details
#initialize(source, widget) ⇒ WebListDataSource
Returns a new instance of WebListDataSource.
12 13 14 15 16 17 18 19 |
# File 'lib/mxrb/compiler/web_list_data_source.rb', line 12 def initialize(source, ) @source = source @widget = resolve_sources resolve_flows resolve_entity @xpath_constraint = @xpath&.fetch('XPathConstraint', '').to_s end |
Instance Attribute Details
#association_path ⇒ Object (readonly)
Returns the value of attribute association_path.
10 11 12 |
# File 'lib/mxrb/compiler/web_list_data_source.rb', line 10 def association_path @association_path end |
#entity ⇒ Object (readonly)
Returns the value of attribute entity.
10 11 12 |
# File 'lib/mxrb/compiler/web_list_data_source.rb', line 10 def entity @entity end |
#microflow_name ⇒ Object (readonly)
Returns the value of attribute microflow_name.
10 11 12 |
# File 'lib/mxrb/compiler/web_list_data_source.rb', line 10 def microflow_name @microflow_name end |
#nanoflow_name ⇒ Object (readonly)
Returns the value of attribute nanoflow_name.
10 11 12 |
# File 'lib/mxrb/compiler/web_list_data_source.rb', line 10 def nanoflow_name @nanoflow_name end |
#xpath_constraint ⇒ Object (readonly)
Returns the value of attribute xpath_constraint.
10 11 12 |
# File 'lib/mxrb/compiler/web_list_data_source.rb', line 10 def xpath_constraint @xpath_constraint end |
Instance Method Details
#association? ⇒ Boolean
58 |
# File 'lib/mxrb/compiler/web_list_data_source.rb', line 58 def association? = !@association_source.nil? && !association_path.empty? && !entity.empty? |
#flow_name(source, key) ⇒ Object
36 37 38 39 40 |
# File 'lib/mxrb/compiler/web_list_data_source.rb', line 36 def flow_name(source, key) source&.dig("#{key}Settings", key).to_s.then do |name| name.empty? ? source&.fetch(key, '').to_s : name end end |
#microflow? ⇒ Boolean
59 |
# File 'lib/mxrb/compiler/web_list_data_source.rb', line 59 def microflow? = !@microflow_source.nil? && !microflow_name.empty? && !@flow.nil? |
#nanoflow? ⇒ Boolean
60 |
# File 'lib/mxrb/compiler/web_list_data_source.rb', line 60 def nanoflow? = !@nanoflow_source.nil? && !nanoflow_name.empty? && !@nanoflow.nil? |
#resolve_entity ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/mxrb/compiler/web_list_data_source.rb', line 47 def resolve_entity @entity = [ entity_ref_destination(@xpath&.fetch('EntityRef', nil)), entity_ref_destination(@association_source&.fetch('EntityRef', nil)), @flow&.document&.dig('MicroflowReturnType', 'Entity'), @nanoflow&.document&.dig('MicroflowReturnType', 'Entity') ].map(&:to_s).find { !_1.empty? }.to_s end |
#resolve_flows ⇒ Object
42 43 44 45 |
# File 'lib/mxrb/compiler/web_list_data_source.rb', line 42 def resolve_flows @flow = qualified_unit('Microflows$Microflow', microflow_name) unless microflow_name.empty? @nanoflow = qualified_unit('Microflows$Nanoflow', nanoflow_name) unless nanoflow_name.empty? end |
#resolve_sources ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mxrb/compiler/web_list_data_source.rb', line 21 def resolve_sources direct = ['DataSource'] if .is_a?(Hash) @xpath = direct if database_source?(direct) @xpath ||= nested(, 'CustomWidgets$CustomWidgetXPathSource').first @association_source = direct if direct&.fetch('$Type', nil) == 'Forms$AssociationSource' @association_source ||= nested(, 'Forms$AssociationSource').first @microflow_source = direct if direct&.fetch('$Type', nil) == 'Forms$MicroflowSource' @microflow_source ||= nested(, 'Forms$MicroflowSource').first @nanoflow_source = direct if direct&.fetch('$Type', nil) == 'Forms$NanoflowSource' @nanoflow_source ||= nested(, 'Forms$NanoflowSource').first @microflow_name = flow_name(@microflow_source, 'Microflow') @nanoflow_name = @nanoflow_source&.fetch('Nanoflow', '').to_s @association_path = entity_ref_path(@association_source&.fetch('EntityRef', nil)) end |
#supported? ⇒ Boolean
56 |
# File 'lib/mxrb/compiler/web_list_data_source.rb', line 56 def supported? = xpath? || association? || microflow? || nanoflow? |
#xpath? ⇒ Boolean
57 |
# File 'lib/mxrb/compiler/web_list_data_source.rb', line 57 def xpath? = !@xpath.nil? || connector_fallback? |