Class: Aikido::Zen::AttackWave::Sample

Inherits:
Object
  • Object
show all
Defined in:
lib/aikido/zen/attack_wave.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(verb:, path:) ⇒ Sample

Returns a new instance of Sample.



162
163
164
165
# File 'lib/aikido/zen/attack_wave.rb', line 162

def initialize(verb:, path:)
  @verb = verb
  @path = path
end

Instance Attribute Details

#pathString (readonly)

Returns:

  • (String)


160
161
162
# File 'lib/aikido/zen/attack_wave.rb', line 160

def path
  @path
end

#verbString (readonly)

Returns:

  • (String)


157
158
159
# File 'lib/aikido/zen/attack_wave.rb', line 157

def verb
  @verb
end

Class Method Details

.from_json(data) ⇒ Object



152
153
154
# File 'lib/aikido/zen/attack_wave.rb', line 152

def self.from_json(data)
  new(verb: data["method"], path: data["url"])
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



174
175
176
177
178
# File 'lib/aikido/zen/attack_wave.rb', line 174

def ==(other)
  other.is_a?(self.class) &&
    other.verb == verb &&
    other.path == path
end

#as_jsonObject



167
168
169
170
171
172
# File 'lib/aikido/zen/attack_wave.rb', line 167

def as_json
  {
    "method" => @verb.as_json,
    "url" => @path.as_json
  }.compact
end

#hashObject



181
182
183
# File 'lib/aikido/zen/attack_wave.rb', line 181

def hash
  [verb, path].hash
end