Sha256: 34f96eb43d31a47fe082313cfb9bf30012bae44ad19f3dca19c303f4e651aafe

Contents?: true

Size: 664 Bytes

Versions: 9

Compression:

Stored size: 664 Bytes

Contents

module Raven

  INTERFACES = {}

  class Interface
    def initialize(attributes = nil)
      attributes.each do |attr, value|
        public_send "#{attr}=", value
      end if attributes

      yield self if block_given?
    end

    def self.name(value = nil)
      @interface_name ||= value
    end

    def to_hash
      Hash[instance_variables.map { |name| [name[1..-1].to_sym, instance_variable_get(name)] } ]
    end
  end

  def self.register_interface(mapping)
    mapping.each_pair do |key, klass|
      INTERFACES[key.to_s] = klass
      INTERFACES[klass.name] = klass
    end
  end

  def self.find_interface(name)
    INTERFACES[name.to_s]
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sentry-raven-0.15.3 lib/raven/interfaces.rb
sentry-raven-0.15.2 lib/raven/interfaces.rb
sentry-raven-0.15.1 lib/raven/interfaces.rb
sentry-raven-0.15.0 lib/raven/interfaces.rb
sentry-raven-0.14.0 lib/raven/interfaces.rb
sentry-raven-0.13.3 lib/raven/interfaces.rb
sentry-raven-0.13.2 lib/raven/interfaces.rb
sentry-raven-0.13.1 lib/raven/interfaces.rb
sentry-raven-0.13.0 lib/raven/interfaces.rb