Sha256: 5c87f611dcde0343436fb8cbe7d6788340313026d78472409d947427d3cd3e9f

Contents?: true

Size: 709 Bytes

Versions: 3

Compression:

Stored size: 709 Bytes

Contents

require 'hashie'

module Raven

  INTERFACES = {}

  class Interface < Hashie::Dash
    def initialize(attributes = {}, &block)
      @check_required = false
      super(attributes)
      block.call(self) if block
      @check_required = true
      assert_required_properties_set!
    end

    def assert_required_properties_set!
      super if @check_required
    end

    def self.name(value = nil)
      @interface_name = value if value
      @interface_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

3 entries across 3 versions & 1 rubygems

Version Path
sentry-raven-0.9.1 lib/raven/interfaces.rb
sentry-raven-0.9.0 lib/raven/interfaces.rb
sentry-raven-0.8.0 lib/raven/interfaces.rb