Class: Houston::Extensions::Event

Inherits:
Struct
  • Object
show all
Defined in:
lib/houston/boot/extensions/events.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ Event

Returns a new instance of Event.



69
70
71
72
73
74
# File 'lib/houston/boot/extensions/events.rb', line 69

def initialize(name, options)
  super name,
    options.fetch(:description),
    options.fetch(:params, [])
  @matcher = Regexp.new("\\A#{name.gsub /\{([^:}]+)\}/, "(?<\\1>[^:]+)"}\\z")
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



68
69
70
# File 'lib/houston/boot/extensions/events.rb', line 68

def description
  @description
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



68
69
70
# File 'lib/houston/boot/extensions/events.rb', line 68

def name
  @name
end

#paramsObject

Returns the value of attribute params

Returns:

  • (Object)

    the current value of params



68
69
70
# File 'lib/houston/boot/extensions/events.rb', line 68

def params
  @params
end

Instance Method Details

#matches?(event_name) ⇒ Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/houston/boot/extensions/events.rb', line 76

def matches?(event_name)
  @matcher === event_name # TODO: replace `===` with `.match?` on Ruby 2.4
end