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



27
28
29
# File '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



8
9
10
11
12
13
14
# File '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



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

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