Class: OnlyofficeTestrailWrapper::TestrailApiObject
- Inherits:
-
Object
- Object
- OnlyofficeTestrailWrapper::TestrailApiObject
- Defined in:
- lib/onlyoffice_testrail_wrapper/testrail_api_object.rb
Overview
Base class for all Testrail API objects
Direct Known Subclasses
Testrail2, TestrailCase, TestrailMilestone, TestrailPlan, TestrailPlanEntry, TestrailProject, TestrailResult, TestrailRun, TestrailSection, TestrailSuite, TestrailTest
Instance Method Summary collapse
-
#init_from_hash(hash) ⇒ Object
Fill object data from hash with data.
-
#name_id_pairs(array, name_key = 'name') ⇒ Hash
Generate hash wih pars of name:id.
Instance Method Details
#init_from_hash(hash) ⇒ Object
Fill object data from hash with data
9 10 11 12 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_api_object.rb', line 9 def init_from_hash(hash) hash.each { |key, value| instance_variable_set(:"@#{key}", value) } self end |
#name_id_pairs(array, name_key = 'name') ⇒ Hash
Generate hash wih pars of name:id
18 19 20 21 22 23 24 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_api_object.rb', line 18 def name_id_pairs(array, name_key = 'name') raise 'First argument must be Array!' unless array.is_a?(Array) result_hash = {} array.reverse_each { |element| result_hash[element[name_key]] = element['id'] } result_hash end |