Class: Yaic::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/yaic/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, message: nil, **attributes) ⇒ Event

Returns a new instance of Event.



7
8
9
10
11
# File 'lib/yaic/event.rb', line 7

def initialize(type:, message: nil, **attributes)
  @type = type
  @message = message
  @attributes = attributes
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object (private)



27
28
29
30
31
32
33
# File 'lib/yaic/event.rb', line 27

def method_missing(method_name, *args)
  if @attributes.key?(method_name) && args.empty?
    @attributes[method_name]
  else
    super
  end
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'lib/yaic/event.rb', line 5

def message
  @message
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/yaic/event.rb', line 5

def type
  @type
end

Instance Method Details

#[](key) ⇒ Object



13
14
15
# File 'lib/yaic/event.rb', line 13

def [](key)
  @attributes[key]
end

#to_hObject



17
18
19
# File 'lib/yaic/event.rb', line 17

def to_h
  @attributes.dup
end