Sha256: 32b94a1498e39056daf88051366a466255913446a7f82dd18fa6f5d90bfd073b

Contents?: true

Size: 875 Bytes

Versions: 5

Compression:

Stored size: 875 Bytes

Contents

require_relative 'base'
require_relative 'milestone'

module Gitlab
  module Triage
    module Resource
      class Context < Base
        EvaluationError = Class.new(RuntimeError)

        def eval(ruby)
          instance_eval <<~RUBY
            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

        private

        def milestone
          @milestone ||=
            resource[:milestone] && Milestone.new(resource[:milestone], net)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gitlab-triage-0.10.0 lib/gitlab/triage/resource/context.rb
gitlab-triage-0.9.0 lib/gitlab/triage/resource/context.rb
gitlab-triage-0.8.1 lib/gitlab/triage/resource/context.rb
gitlab-triage-0.8.0 lib/gitlab/triage/resource/context.rb
gitlab-triage-0.7.0 lib/gitlab/triage/resource/context.rb