Class: Mxrb::Compiler::LegacyCustomWidgetCompiler
- Inherits:
-
Object
- Object
- Mxrb::Compiler::LegacyCustomWidgetCompiler
- Includes:
- ModelValues
- Defined in:
- lib/mxrb/compiler/legacy_custom_widget_compiler.rb
Overview
Serializes schema-described Mendix 6/7 custom widgets to their Dojo client contract. rubocop:disable Metrics
Constant Summary collapse
- SUPPORTED_TYPES =
%w[ Attribute Boolean Decimal Entity EntityConstraint Enumeration Form Image Integer Microflow String System TranslatableString Object ].freeze
Instance Attribute Summary collapse
-
#widget_id ⇒ Object
readonly
Returns the value of attribute widget_id.
Instance Method Summary collapse
-
#initialize(source, widget, language:) ⇒ LegacyCustomWidgetCompiler
constructor
A new instance of LegacyCustomWidgetCompiler.
- #properties_hash ⇒ Object
- #supported? ⇒ Boolean
Constructor Details
#initialize(source, widget, language:) ⇒ LegacyCustomWidgetCompiler
Returns a new instance of LegacyCustomWidgetCompiler.
19 20 21 22 23 24 25 26 |
# File 'lib/mxrb/compiler/legacy_custom_widget_compiler.rb', line 19 def initialize(source, , language:) @source = source @widget = @language = language @widget_type = ['Type'] || {} @widget_id = @widget_type['WidgetId'].to_s @schema_index = schema_index(@widget_type) end |
Instance Attribute Details
#widget_id ⇒ Object (readonly)
Returns the value of attribute widget_id.
17 18 19 |
# File 'lib/mxrb/compiler/legacy_custom_widget_compiler.rb', line 17 def @widget_id end |
Instance Method Details
#properties_hash ⇒ Object
35 36 37 38 39 40 |
# File 'lib/mxrb/compiler/legacy_custom_widget_compiler.rb', line 35 def properties_hash properties(@widget['Object']).to_h do |property| schema = property_schema(property) [schema['PropertyKey'].to_s, compile_value(schema.dig('ValueType', 'Type'), property['Value'])] end end |
#supported? ⇒ Boolean
28 29 30 31 32 33 |
# File 'lib/mxrb/compiler/legacy_custom_widget_compiler.rb', line 28 def supported? !.empty? && package_module? && properties(@widget['Object']).all? do |property| type = property_type(property) SUPPORTED_TYPES.include?(type) && supported_value?(type, property['Value']) end end |