Class: Usps::Imis::BusinessObjectMock
- Inherits:
-
Object
- Object
- Usps::Imis::BusinessObjectMock
- Defined in:
- lib/usps/imis/business_object_mock.rb
Overview
Mock data response for testing
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Instance Method Summary collapse
- #delete ⇒ Object
- #get ⇒ Object
- #get_field(name) ⇒ Object
-
#initialize(**fields) ⇒ BusinessObjectMock
constructor
A new instance of BusinessObjectMock.
- #post(data) ⇒ Object
- #put(data) ⇒ Object
- #put_fields(data) ⇒ Object
Constructor Details
#initialize(**fields) ⇒ BusinessObjectMock
Returns a new instance of BusinessObjectMock.
10 11 12 |
# File 'lib/usps/imis/business_object_mock.rb', line 10 def initialize(**fields) @fields = fields.transform_keys(&:to_s) end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
8 9 10 |
# File 'lib/usps/imis/business_object_mock.rb', line 8 def fields @fields end |
Instance Method Details
#delete ⇒ Object
32 |
# File 'lib/usps/imis/business_object_mock.rb', line 32 def delete = '' |
#get ⇒ Object
16 17 18 19 20 |
# File 'lib/usps/imis/business_object_mock.rb', line 16 def get Usps::Imis::Properties.build do |props| fields.each { |name, value| props.add(name, value) } end end |
#get_field(name) ⇒ Object
14 |
# File 'lib/usps/imis/business_object_mock.rb', line 14 def get_field(name) = fields[name] |
#post(data) ⇒ Object
30 |
# File 'lib/usps/imis/business_object_mock.rb', line 30 def post(data) = data |
#put(data) ⇒ Object
28 |
# File 'lib/usps/imis/business_object_mock.rb', line 28 def put(data) = data |
#put_fields(data) ⇒ Object
22 23 24 25 26 |
# File 'lib/usps/imis/business_object_mock.rb', line 22 def put_fields(data) Usps::Imis::Properties.build do |props| fields.merge(data.transform_keys(&:to_s)).each { |name, value| props.add(name, value) } end end |