Class: Allure::JSONable
- Inherits:
-
Object
- Object
- Allure::JSONable
- Defined in:
- lib/allure_ruby_commons/model/01_jsonable.rb
Overview
General jsonable object implementation
Direct Known Subclasses
Attachment, Category, ExecutableItem, Label, Link, Parameter, StatusDetails, TestResultContainer
Instance Method Summary collapse
-
#==(other) ⇒ Booelan
Object comparator.
-
#to_hash ⇒ Hash
Return object hash represantation.
-
#to_json(*options) ⇒ String
Return object json string.
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_hash ⇒ Hash
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(*) to_hash.to_json(*) end |