Class: TypedEnums::Output::JavaScriptFile
- Inherits:
-
Object
- Object
- TypedEnums::Output::JavaScriptFile
- Defined in:
- lib/typed_enums/output/javascript_file.rb
Constant Summary collapse
- HEADER =
"// AUTO-GENERATED BY typed_enums. DO NOT EDIT."
Instance Method Summary collapse
-
#initialize(model_groups:) ⇒ JavaScriptFile
constructor
A new instance of JavaScriptFile.
- #render ⇒ Object
- #schema_hash ⇒ Object
Constructor Details
#initialize(model_groups:) ⇒ JavaScriptFile
Returns a new instance of JavaScriptFile.
11 12 13 |
# File 'lib/typed_enums/output/javascript_file.rb', line 11 def initialize(model_groups:) @model_groups = model_groups end |
Instance Method Details
#render ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/typed_enums/output/javascript_file.rb', line 15 def render <<~JAVASCRIPT #{HEADER} // enum-schema-sha256: #{schema_hash} #{model_exports} JAVASCRIPT end |
#schema_hash ⇒ Object
24 25 26 |
# File 'lib/typed_enums/output/javascript_file.rb', line 24 def schema_hash Digest::SHA256.hexdigest(JSON.generate(schema)) end |