Class: Fare::Topic

Inherits:
Object
  • Object
show all
Defined in:
lib/fare/topic.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Topic

Returns a new instance of Topic.



6
7
8
9
10
# File 'lib/fare/topic.rb', line 6

def initialize(options)
  @subject = options.fetch(:subject)
  @action  = options.fetch(:action)
  @version = options[:version]
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



4
5
6
# File 'lib/fare/topic.rb', line 4

def action
  @action
end

#subjectObject (readonly)

Returns the value of attribute subject.



4
5
6
# File 'lib/fare/topic.rb', line 4

def subject
  @subject
end

#versionObject (readonly)

Returns the value of attribute version.



4
5
6
# File 'lib/fare/topic.rb', line 4

def version
  @version
end

Instance Method Details

#[](key) ⇒ Object



16
17
18
# File 'lib/fare/topic.rb', line 16

def [](key)
  public_send(key)
end

#fetch(key) ⇒ Object



20
21
22
# File 'lib/fare/topic.rb', line 20

def fetch(key)
  public_send(key)
end

#handles?(event) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/fare/topic.rb', line 12

def handles?(event)
  subject.to_s == event.subject && action.to_s == event.action
end