Class: Brainstem::TestHelpers::BrainstemDataHelper
- Inherits:
-
Object
- Object
- Brainstem::TestHelpers::BrainstemDataHelper
- Defined in:
- lib/brainstem/test_helpers.rb
Defined Under Namespace
Classes: BrainstemHelperCollection, BrainstemHelperItem
Instance Method Summary collapse
-
#initialize(response_body) ⇒ BrainstemDataHelper
constructor
A new instance of BrainstemDataHelper.
- #method_missing(name) ⇒ Object
- #results ⇒ Object
Constructor Details
#initialize(response_body) ⇒ BrainstemDataHelper
Returns a new instance of BrainstemDataHelper.
35 36 37 |
# File 'lib/brainstem/test_helpers.rb', line 35 def initialize(response_body) @json = JSON.parse(response_body) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
43 44 45 46 |
# File 'lib/brainstem/test_helpers.rb', line 43 def method_missing(name) data = @json[name.to_s].try(:values) BrainstemHelperCollection.new(data) unless data.nil? end |
Instance Method Details
#results ⇒ Object
39 40 41 |
# File 'lib/brainstem/test_helpers.rb', line 39 def results BrainstemHelperCollection.new(@json['results'].map { |ref| @json[ref['key']][ref['id']] }) end |