Class: Moku6::Generators::RubyGenerator

Inherits:
BaseGenerator show all
Defined in:
lib/moku6/generators/ruby_generator.rb

Overview

Emits Ruby constants for every action (design section 12.4).

Constant Summary

Constants inherited from BaseGenerator

BaseGenerator::AUTOGEN_NOTE

Instance Method Summary collapse

Methods inherited from BaseGenerator

#initialize, #write

Constructor Details

This class inherits a constructor from Moku6::Generators::BaseGenerator

Instance Method Details

#renderObject

: () -> String



9
10
11
12
13
14
15
16
17
18
# File 'lib/moku6/generators/ruby_generator.rb', line 9

def render
  consts = @catalog.sorted.map { |e| [const_name(e), e.action] }
  out = ["# frozen_string_literal: true", "# #{AUTOGEN_NOTE}", "module AuditEvents"]
  consts.each { |name, action| out << "  #{name} = #{action.inspect}" }
  out << ""
  out << "  ALL = [#{consts.map(&:first).join(", ")}].freeze"
  out << "end"
  out << ""
  out.join("\n")
end