lib/relevance/tarantula/attack.rb in tarantula-0.3.3 vs lib/relevance/tarantula/attack.rb in tarantula-0.4.0

- old
+ new

@@ -1,18 +1,22 @@ -class Relevance::Tarantula::Attack - HASHABLE_ATTRS = [:name, :input, :output, :description] - attr_accessor *HASHABLE_ATTRS - def initialize(hash) - hash.each do |k,v| - raise ArgumentError, k unless HASHABLE_ATTRS.member?(k) - self.instance_variable_set("@#{k}", v) +module Relevance + module Tarantula + + class Attack + HASHABLE_ATTRS = [:name, :input, :output, :description] + attr_accessor *HASHABLE_ATTRS + def initialize(hash) + hash.each do |k,v| + raise ArgumentError, k unless HASHABLE_ATTRS.member?(k) + self.instance_variable_set("@#{k}", v) + end + end + def ==(other) + Relevance::Tarantula::Attack === other && HASHABLE_ATTRS.all? { |attr| send(attr) == other.send(attr)} + end + def input(input_field=nil) + @input + end end + end - def ==(other) - Relevance::Tarantula::Attack === other && HASHABLE_ATTRS.all? { |attr| send(attr) == other.send(attr)} - end - def input(input_field=nil) - @input - end end - -