Sha256: 8fa488b8bf41db2ee4b4c5bb2e48fd8846b107ad2d3dcb2e4a233765891a35ee

Contents?: true

Size: 647 Bytes

Versions: 9

Compression:

Stored size: 647 Bytes

Contents

require 'opbeat/better_attr_accessor'

module Opbeat

  INTERFACES = {}

  class Interface
    include BetterAttrAccessor
    alias_method :to_hash, :attributes

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

      yield self if block_given?
    end

    def self.name(value = nil)
      @interface_name ||= value
    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 & 2 rubygems

Version Path
kuende-opbeat-2.0.4 lib/opbeat/interfaces.rb
kuende-opbeat-2.0.3 lib/opbeat/interfaces.rb
kuende-opbeat-2.0.2 lib/opbeat/interfaces.rb
kuende-opbeat-2.0.1 lib/opbeat/interfaces.rb
opbeat-2.0.0 lib/opbeat/interfaces.rb
opbeat-1.1.1 lib/opbeat/interfaces.rb
opbeat-1.1.0 lib/opbeat/interfaces.rb
opbeat-1.0.0 lib/opbeat/interfaces.rb
opbeat-0.9.2 lib/opbeat/interfaces.rb