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.32 lib/ree/dsl/error_dsl.rb
ree-1.0.31 lib/ree/dsl/error_dsl.rb
ree-1.0.30 lib/ree/dsl/error_dsl.rb
ree-1.0.29 lib/ree/dsl/error_dsl.rb
ree-1.0.28 lib/ree/dsl/error_dsl.rb
ree-1.0.27 lib/ree/dsl/error_dsl.rb
ree-1.0.26 lib/ree/dsl/error_dsl.rb
ree-1.0.25 lib/ree/dsl/error_dsl.rb
ree-1.0.24 lib/ree/dsl/error_dsl.rb
ree-1.0.23 lib/ree/dsl/error_dsl.rb
ree-1.0.22 lib/ree/dsl/error_dsl.rb
ree-1.0.21 lib/ree/dsl/error_dsl.rb
ree-1.0.20 lib/ree/dsl/error_dsl.rb
ree-1.0.19 lib/ree/dsl/error_dsl.rb
ree-1.0.18 lib/ree/dsl/error_dsl.rb
ree-1.0.17 lib/ree/dsl/error_dsl.rb
ree-1.0.16 lib/ree/dsl/error_dsl.rb
ree-1.0.15 lib/ree/dsl/error_dsl.rb
ree-1.0.14 lib/ree/dsl/error_dsl.rb
ree-1.0.13 lib/ree/dsl/error_dsl.rb