Class: Raven::Interface

Inherits:
Object show all
Defined in:
lib/raven/interface.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = nil) {|_self| ... } ⇒ Interface

Returns a new instance of Interface.

Yields:

  • (_self)

Yield Parameters:



3
4
5
6
7
8
9
# File 'lib/raven/interface.rb', line 3

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

  yield self if block_given?
end

Class Method Details

.inherited(klass) ⇒ Object



11
12
13
14
15
# File 'lib/raven/interface.rb', line 11

def self.inherited(klass)
  name = klass.name.split("::").last.downcase.gsub("interface", "")
  registered[name.to_sym] = klass
  super
end

.registeredObject



17
18
19
# File 'lib/raven/interface.rb', line 17

def self.registered
  @@registered ||= {} # rubocop:disable Style/ClassVars
end

Instance Method Details

#to_hashObject



21
22
23
# File 'lib/raven/interface.rb', line 21

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