Module: StateMachines::SyntaxValidator::RubyVmBackend

Defined in:
lib/state_machines/syntax_validator.rb

Overview

MRI backend using RubyVM::InstructionSequence

Class Method Summary collapse

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/state_machines/syntax_validator.rb', line 30

def available?
  RUBY_ENGINE == 'ruby'
end

.validate!(code, filename) ⇒ Object



35
36
37
38
39
# File 'lib/state_machines/syntax_validator.rb', line 35

def validate!(code, filename)
  # compile will raise a SyntaxError on bad syntax
  RubyVM::InstructionSequence.compile(code, filename)
  true
end