Sha256: 26d80eeaa10d4723d8b6a33e51312f1e4a87ba480458f7c9642a36b51ce043aa

Contents?: true

Size: 450 Bytes

Versions: 33

Compression:

Stored size: 450 Bytes

Contents

# frozen_string_literal  = true

class Ree::ErrorDsl
  def execute(klass, &proc)
    self.class.instance_exec(&proc)
  rescue NameError => e
    proc
      .binding
      .eval("#{e.name} = Ree::ErrorDsl::ClassConstant.new('#{e.name}')")

    retry
  end

  class ClassConstant
    attr_reader :name, :message

    def initialize(name)
      @name = name
      @message = nil
    end

    def [](msg)
      @message = msg
      self
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
ree-1.0.12 lib/ree/dsl/error_dsl.rb
ree-1.0.11 lib/ree/dsl/error_dsl.rb
ree-1.0.10 lib/ree/dsl/error_dsl.rb
ree-1.0.9 lib/ree/dsl/error_dsl.rb
ree-1.0.8 lib/ree/dsl/error_dsl.rb
ree-1.0.7 lib/ree/dsl/error_dsl.rb
ree-1.0.6 lib/ree/dsl/error_dsl.rb
ree-1.0.5 lib/ree/dsl/error_dsl.rb
ree-1.0.4 lib/ree/dsl/error_dsl.rb
ree-1.0.3 lib/ree/dsl/error_dsl.rb
ree-1.0.2 lib/ree/dsl/error_dsl.rb
ree-1.0.1 lib/ree/dsl/error_dsl.rb
ree-1.0.0 lib/ree/dsl/error_dsl.rb