Module: Gitlab::Triage::Resource::Context
- Defined in:
- lib/gitlab/triage/resource/context.rb
Constant Summary collapse
- EvaluationError =
Class.new(RuntimeError)
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.build(resource, **options) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/gitlab/triage/resource/context.rb', line 17 def self.build(resource, **) const_name = (resource[:type] || 'Base') .to_s.singularize.camelcase Resource.const_get(const_name).new(resource, **).extend(self) end |
Instance Method Details
#eval(ruby) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gitlab/triage/resource/context.rb', line 24 def eval(ruby) instance_eval <<~RUBY, __FILE__, __LINE__ + 1 begin #{ruby} rescue StandardError, ScriptError => e raise EvaluationError.new(e.message) end RUBY rescue EvaluationError => e # This way we could obtain the original backtrace and error # If we just let instance_eval raise an error, the backtrace # won't contain the actual line where it's giving an error. raise e.cause end |
#instance_version ⇒ Object (private)
41 42 43 |
# File 'lib/gitlab/triage/resource/context.rb', line 41 def instance_version @instance_version ||= InstanceVersion.new(parent: self) end |