Class: Allure::JSONable

Inherits:
Object
  • Object
show all
Defined in:
allure-ruby-commons/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)


27
28
29
# File 'allure-ruby-commons/lib/allure_ruby_commons/model/01_jsonable.rb', line 27

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

#to_hashHash

Return object hash represantation

Returns:

  • (Hash)


8
9
10
11
12
13
14
# File 'allure-ruby-commons/lib/allure_ruby_commons/model/01_jsonable.rb', line 8

def to_hash
  json_attributes.each_with_object({}) do |attribute, map|
    key = camelcase(attribute)
    value = send(attribute) # fetch via reader for dynamically generated attributes
    map[key] = value unless value.nil?
  end
end

#to_json(*options) ⇒ String

Return object json string

Parameters:

  • *options (Array)

Returns:

  • (String)


20
21
22
# File 'allure-ruby-commons/lib/allure_ruby_commons/model/01_jsonable.rb', line 20

def to_json(*options)
  to_hash.to_json(*options)
end