Class: Cucumber::Messages::Hook

Inherits:
Message
  • Object
show all
Defined in:
lib/cucumber/messages/hook.rb

Overview

Represents the Hook message in Cucumber’s message protocol.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Message

camelize, from_json, #to_h, #to_json

Constructor Details

#initialize(id: '', name: nil, source_reference: SourceReference.new, tag_expression: nil, type: nil) ⇒ Hook

Returns a new instance of Hook.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/cucumber/messages/hook.rb', line 21

def initialize(
  id: '',
  name: nil,
  source_reference: SourceReference.new,
  tag_expression: nil,
  type: nil
)
  @id = id
  @name = name
  @source_reference = source_reference
  @tag_expression = tag_expression
  @type = type
  super()
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



11
12
13
# File 'lib/cucumber/messages/hook.rb', line 11

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/cucumber/messages/hook.rb', line 13

def name
  @name
end

#source_referenceObject (readonly)

Returns the value of attribute source_reference.



15
16
17
# File 'lib/cucumber/messages/hook.rb', line 15

def source_reference
  @source_reference
end

#tag_expressionObject (readonly)

Returns the value of attribute tag_expression.



17
18
19
# File 'lib/cucumber/messages/hook.rb', line 17

def tag_expression
  @tag_expression
end

#typeObject (readonly)

Returns the value of attribute type.



19
20
21
# File 'lib/cucumber/messages/hook.rb', line 19

def type
  @type
end

Class Method Details

.from_h(hash) ⇒ Object

Returns a new Hook from the given hash. If the hash keys are camelCased, they are properly assigned to the corresponding snake_cased attributes.

Cucumber::Messages::Hook.from_h(some_hash) # => #<Cucumber::Messages::Hook:0x... ...>


43
44
45
46
47
48
49
50
51
52
53
# File 'lib/cucumber/messages/hook.rb', line 43

def self.from_h(hash)
  return nil if hash.nil?

  new(
    id: hash[:id],
    name: hash[:name],
    source_reference: SourceReference.from_h(hash[:sourceReference]),
    tag_expression: hash[:tagExpression],
    type: hash[:type]
  )
end