Class: Allure::JSONable

Inherits:
Object
  • Object
show all
Defined in:
lib/allure_ruby_commons/model/01_jsonable.rb

Overview

General jsonable object implementation

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Booelan

Object comparator

Parameters:

Returns:

  • (Booelan)


23
24
25
# File 'lib/allure_ruby_commons/model/01_jsonable.rb', line 23

def ==(other)
  self.class == other.class && state == other.state
end

#to_hashHash

Return object hash represantation

Returns:

  • (Hash)


12
13
14
15
16
17
18
# File 'lib/allure_ruby_commons/model/01_jsonable.rb', line 12

def to_hash
  instance_variables.each_with_object({}) do |var, map|
    key = camelcase(var.to_s.delete_prefix("@"))
    value = instance_variable_get(var)
    map[key] = value unless value.nil?
  end
end