Module: StateMachines::SyntaxValidator
- Defined in:
- lib/state_machines/syntax_validator.rb
Overview
Cross-platform syntax validation for eval strings Supports CRuby, JRuby, TruffleRuby via pluggable backends
Defined Under Namespace
Modules: RubyVmBackend, UniversalBackend
Class Method Summary collapse
-
.backend ⇒ Object
Lazily pick the best backend for this platform Prefer RubyVM for performance on CRuby, fallback to eval for compatibility.
-
.validate!(code, filename = '(eval)') ⇒ Object
Public API: raises SyntaxError if code is invalid.
Class Method Details
.backend ⇒ Object
Lazily pick the best backend for this platform Prefer RubyVM for performance on CRuby, fallback to eval for compatibility
17 18 19 20 21 22 23 |
# File 'lib/state_machines/syntax_validator.rb', line 17 def backend @backend ||= if RubyVmBackend.available? RubyVmBackend else UniversalBackend end end |
.validate!(code, filename = '(eval)') ⇒ Object
Public API: raises SyntaxError if code is invalid
8 9 10 |
# File 'lib/state_machines/syntax_validator.rb', line 8 def validate!(code, filename = '(eval)') backend.validate!(code, filename) end |