Sha256: a806ef26b383f366992092ddc88c9532417d28ebf5ba6abecabee79786e10a22

Contents?: true

Size: 844 Bytes

Versions: 5

Compression:

Stored size: 844 Bytes

Contents

# frozen_string_literal: true

# Ruby 3.2
unless Exception.method_defined?(:detailed_message)
  class Exception
    alias detailed_message message
  end
end

# Ruby 3.2
unless defined?(Data)
  class Data
    class << self
      def define(*syms)
        _ = Class.new do |c|
          define_method(:initialize) do |*args, **kwargs|
            if !args.empty?
              syms.zip(args).each do |sym, arg|
                instance_variable_set("@#{sym}", arg)
              end
            end
            if !kwargs.empty?
              kwargs.each do |k, v|
                instance_variable_set("@#{k}", v)
              end
            end
          end

          syms.each do |sym|
            c.define_method(sym) do
              instance_variable_get("@#{sym}")
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
raap-1.0.0 lib/shims.rb
raap-0.10.0 lib/shims.rb
raap-0.9.0 lib/shims.rb
raap-0.8.0 lib/shims.rb
raap-0.6.0 lib/shims.rb