Class: AWS::Core::XML::Stub
- Inherits:
-
Object
- Object
- AWS::Core::XML::Stub
- Defined in:
- lib/aws/core/xml/stub.rb
Overview
This class takes the rules from an XML parser and then returns a stubbed reponse. This response has placeholder values based on the grammar, e.g.
-
Lists are stubbed with empty arrays
-
Indexes become empty hashes
-
Numeric types are returned as 0
-
etc
This is used primarily to help with the AWS.stub! utility.
Instance Attribute Summary collapse
- #rules ⇒ Hash readonly
Class Method Summary collapse
-
.simulate(rules) ⇒ Hash
Returns a hash with stubbed values as if it had parsed an empty xml document.
Instance Method Summary collapse
-
#initialize(rules) ⇒ Stub
constructor
A new instance of Stub.
-
#simulate ⇒ Hash
Returns a hash with stubbed values as if it had parsed an empty xml document.
Constructor Details
#initialize(rules) ⇒ Stub
Returns a new instance of Stub.
32 33 34 |
# File 'lib/aws/core/xml/stub.rb', line 32 def initialize rules @rules = rules end |
Instance Attribute Details
#rules ⇒ Hash (readonly)
37 38 39 |
# File 'lib/aws/core/xml/stub.rb', line 37 def rules @rules end |
Class Method Details
Instance Method Details
#simulate ⇒ Hash
Returns a hash with stubbed values as if it had parsed an empty xml document.
42 43 44 45 46 47 48 49 50 |
# File 'lib/aws/core/xml/stub.rb', line 42 def simulate if rules[:children] data = stub_data_for(rules) apply_empty_indexes(rules, data) data else {} end end |