Class: Mxrb::Compiler::WebOperationCompiler
- Inherits:
-
Object
- Object
- Mxrb::Compiler::WebOperationCompiler
- Includes:
- ModelValues
- Defined in:
- lib/mxrb/compiler/web_operation_compiler.rb
Overview
Builds the Runtime operation catalog consumed by generated web data sources. rubocop:disable Metrics, Style/HashLikeCase, Style/MultilineBlockChain
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(source) ⇒ WebOperationCompiler
constructor
A new instance of WebOperationCompiler.
- #write(path) ⇒ Object
Constructor Details
#initialize(source) ⇒ WebOperationCompiler
Returns a new instance of WebOperationCompiler.
25 26 27 |
# File 'lib/mxrb/compiler/web_operation_compiler.rb', line 25 def initialize(source) @source = source end |
Class Method Details
.menu_operation_id(action) ⇒ Object
19 20 21 22 23 |
# File 'lib/mxrb/compiler/web_operation_compiler.rb', line 19 def self.(action) identifier = IO::BsonCodec.extract_id(action['$ID']).to_s identifier = action.dig('MicroflowSettings', 'Microflow').to_s if identifier.empty? operation_id('Navigation', identifier) end |
.operation_id(page_name, widget_name) ⇒ Object
14 15 16 17 |
# File 'lib/mxrb/compiler/web_operation_compiler.rb', line 14 def self.operation_id(page_name, ) Base64.strict_encode64(Digest::SHA256.digest("#{page_name}/#{}").byteslice(0, 16)) .delete_suffix('==') end |
Instance Method Details
#write(path) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/mxrb/compiler/web_operation_compiler.rb', line 29 def write(path) operations = @source.units_of('Forms$Page').select { web_page?(_1) } .flat_map { page_operations(_1) } if @source.is_a?(SourceModel) operations.concat(@source.units_of('Forms$Layout').select { web_layout?(_1) } .flat_map { page_operations(_1) }) end operations.concat(nanoflow_operations) operations = operations.uniq { _1['operationId'] } File.write(path, JSON.generate(operations)) operations end |