Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Ruby/Rails:如何以易读的方式格式化这种密集的数据结构?_Ruby On Rails_Ruby_Authorize.net - Fatal编程技术网

Ruby on rails Ruby/Rails:如何以易读的方式格式化这种密集的数据结构?

Ruby on rails Ruby/Rails:如何以易读的方式格式化这种密集的数据结构?,ruby-on-rails,ruby,authorize.net,Ruby On Rails,Ruby,Authorize.net,我被迫使用不人道的Authorize.net Ruby SDK进行工作 我从请求@response.transactionResponse返回的响应进入控制台时会产生以下不可原谅的混乱: #<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 @responseCode="1", @rawResponseCode=nil, @authCode="", @avsResultCode=&qu

我被迫使用不人道的Authorize.net Ruby SDK进行工作

我从请求
@response.transactionResponse
返回的响应进入控制台时会产生以下不可原谅的混乱:

#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 @responseCode="1", @rawResponseCode=nil, @authCode="", @avsResultCode="Y", @cvvResultCode="P", @cavvResultCode="2", @transId="xxx", @refTransID="", @transHash="", @testRequest="0", @accountNumber="XXXX4242", @accountType="Visa", @splitTenderId=nil, @prePaidCard=nil, @messages=#<AuthorizeNet::API::TransactionResponse::Messages:0x00007ff79e756c08 @messages=[#<AuthorizeNet::API::TransactionResponse::Messages::Message:0x00007ff79e74c320 @code="1", @description="This transaction has been approved.", @roxml_references=[#<ROXML::XMLTextRef:0x00007ff79e74c0f0 @opts=#<ROXML::Definition:0x00007ff7981bd680 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="code", @array=false, @blocks=[], @sought_type=:text, @attr_name="code", @name="code">, @instance=#<AuthorizeNet::API::TransactionResponse::Messages::Message:0x00007ff79e74c320 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x00007ff79e74c0a0 @opts=#<ROXML::Definition:0x00007ff7981bc4b0 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="description", @array=false, @blocks=[], @sought_type=:text, @attr_name="description", @name="description">, @instance=#<AuthorizeNet::API::TransactionResponse::Messages::Message:0x00007ff79e74c320 ...>, @default_namespace="xmlns">]>], @roxml_references=[#<ROXML::XMLObjectRef:0x00007ff79e756140 @opts=#<ROXML::Definition:0x00007ff79aae7ba0 @default=[], @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="messages", @array=true, @blocks=[], @sought_type=AuthorizeNet::API::TransactionResponse::Messages::Message, @attr_name="messages", @name="message">, @instance=#<AuthorizeNet::API::TransactionResponse::Messages:0x00007ff79e756c08 ...>, @default_namespace="xmlns">]>, @errors=nil, @splitTenderPayments=nil, @userFields=nil, @shipTo=nil, @secureAcceptance=nil, @emvResponse=nil, @transHashSha2="", @profile=#<AuthorizeNet::API::CustomerProfileIdType:0x00007ff79e6eb7c8 @customerProfileId="1516819837", @customerPaymentProfileId="1515258810", @customerAddressId=nil, @roxml_references=[#<ROXML::XMLTextRef:0x00007ff79e6eb6d8 @opts=#<ROXML::Definition:0x00007ff79aab73b0 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="customerProfileId", @array=false, @blocks=[], @sought_type=:text, @attr_name="customerProfileId", @name="customerProfileId">, @instance=#<AuthorizeNet::API::CustomerProfileIdType:0x00007ff79e6eb7c8 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x00007ff79e6eb6b0 @opts=#<ROXML::Definition:0x00007ff79aab6c80 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="customerPaymentProfileId", @array=false, @blocks=[], @sought_type=:text, @attr_name="customerPaymentProfileId", @name="customerPaymentProfileId">, @instance=#<AuthorizeNet::API::CustomerProfileIdType:0x00007ff79e6eb7c8 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x00007ff79e6eb688 @opts=#<ROXML::Definition:0x00007ff79aab65c8 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="customerAddressId", @array=false, @blocks=[], @sought_type=:text, @attr_name="customerAddressId", @name="customerAddressId">, @instance=#<AuthorizeNet::API::CustomerProfileIdType:0x00007ff79e6eb7c8 ...>, @default_namespace="xmlns">]>, @networkTransId="8N6BXPMY1PG3W833NZWYZRZ", @roxml_references=[#<ROXML::XMLTextRef:0x00007ff79af16d70 @opts=#<ROXML::Definition:0x00007ff7981a7da8 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="responseCode", @array=false, @blocks=[], @sought_type=:text, @attr_name="responseCode", @name="responseCode">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x00007ff79af16d48 @opts=#<ROXML::Definition:0x00007ff7981a7178 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="rawResponseCode", @array=false, @blocks=[], @sought_type=:text, @attr_name="rawResponseCode", @name="rawResponseCode">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x00007ff79af16d20 @opts=#<ROXML::Definition:0x00007ff7981a6368 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="authCode", @array=false, @blocks=[], @sought_type=:text, @attr_name="authCode", @name="authCode">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x00007ff79af16cf8 @opts=#<ROXML::Definition:0x00007ff7981a5698 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="avsResultCode", @array=false, @blocks=[], @sought_type=:text, @attr_name="avsResultCode", @name="avsResultCode">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x00007ff79af16cd0 @opts=#<ROXML::Definition:0x00007ff7981a48b0 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="cvvResultCode", @array=false, @blocks=[], @sought_type=:text, @attr_name="cvvResultCode", @name="cvvResultCode">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x00007ff79af16ca8 @opts=#<ROXML::Definition:0x00007ff791e0bc18 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="cavvResultCode", @array=false, @blocks=[], @sought_type=:text, @attr_name="cavvResultCode", @name="cavvResultCode">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x00007ff79af16c80 @opts=#<ROXML::Definition:0x00007ff791e0b560 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="transId", @array=false, @blocks=[], @sought_type=:text, @attr_name="transId", @name="transId">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x00007ff79af16c30 @opts=#<ROXML::Definition:0x00007ff791e0aed0 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="refTransID", @array=false, @blocks=[], @sought_type=:text, @attr_name="refTransID", @name="refTransID">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x00007ff79af16be0 @opts=#<ROXML::Definition:0x00007ff791e0a818 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="transHash", @array=false, @blocks=[], @sought_type=:text, @attr_name="transHash", @name="transHash">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x00007ff79af16b90 @opts=#<ROXML::Definition:0x00007ff791e0a160 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="testRequest", @array=false, @blocks=[], @sought_type=:text, @attr_name="testRequest", @name="testRequest">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x00007ff79af16b40 @opts=#<ROXML::Definition:0x00007ff791e09aa8 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="accountNumber", @array=false, @blocks=[], @sought_type=:text, @attr_name="accountNumber", @name="accountNumber">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x00007ff79af16af0 @opts=#<ROXML::Definition:0x00007ff791e09418 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="accountType", @array=false, @blocks=[], @sought_type=:text, @attr_name="accountType", @name="accountType">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x00007ff79af16aa0 @opts=#<ROXML::Definition:0x00007ff791e08d88 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="splitTenderId", @array=false, @blocks=[], @sought_type=:text, @attr_name="splitTenderId", @name="splitTenderId">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLObjectRef:0x00007ff79af16a50 @opts=#<ROXML::Definition:0x00007ff791e086f8 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="prePaidCard", @array=false, @blocks=[], @sought_type=AuthorizeNet::API::TransactionResponse::PrePaidCard, @attr_name="prePaidCard", @name="prePaidCard">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLObjectRef:0x00007ff79af16a00 @opts=#<ROXML::Definition:0x00007ff791e08090 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="messages", @array=false, @blocks=[], @sought_type=AuthorizeNet::API::TransactionResponse::Messages, @attr_name="messages", @name="messages">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLObjectRef:0x00007ff79af169d8 @opts=#<ROXML::Definition:0x00007ff79819f1f8 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="errors", @array=false, @blocks=[], @sought_type=AuthorizeNet::API::TransactionResponse::Errors, @attr_name="errors", @name="errors">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLObjectRef:0x00007ff79af169b0 @opts=#<ROXML::Definition:0x00007ff79819dba0 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="splitTenderPayments", @array=false, @blocks=[], @sought_type=AuthorizeNet::API::TransactionResponse::SplitTenderPayments, @attr_name="splitTenderPayments", @name="splitTenderPayments">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLObjectRef:0x00007ff79af16988 @opts=#<ROXML::Definition:0x00007ff79819cf98 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="userFields", @array=false, @blocks=[], @sought_type=AuthorizeNet::API::UserFields, @attr_name="userFields", @name="userFields">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLObjectRef:0x00007ff79af16960 @opts=#<ROXML::Definition:0x00007ff79819c200 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="shipTo", @array=false, @blocks=[], @sought_type=AuthorizeNet::API::NameAndAddressType, @attr_name="shipTo", @name="shipTo">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLObjectRef:0x00007ff79af16938 @opts=#<ROXML::Definition:0x00007ff791e13af8 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="secureAcceptance", @array=false, @blocks=[], @sought_type=AuthorizeNet::API::TransactionResponse::SecureAcceptance, @attr_name="secureAcceptance", @name="secureAcceptance">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLObjectRef:0x00007ff79af16910 @opts=#<ROXML::Definition:0x00007ff791e13490 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="emvResponse", @array=false, @blocks=[], @sought_type=AuthorizeNet::API::TransactionResponse::EmvResponse, @attr_name="emvResponse", @name="emvResponse">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x00007ff79af168e8 @opts=#<ROXML::Definition:0x00007ff791e12e28 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="transHashSha2", @array=false, @blocks=[], @sought_type=:text, @attr_name="transHashSha2", @name="transHashSha2">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLObjectRef:0x00007ff79af168c0 @opts=#<ROXML::Definition:0x00007ff791e12770 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="profile", @array=false, @blocks=[], @sought_type=AuthorizeNet::API::CustomerProfileIdType, @attr_name="profile", @name="profile">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">, #<ROXML::XMLTextRef:0x00007ff79af16870 @opts=#<ROXML::Definition:0x00007ff791e12158 @default=nil, @to_xml=nil, @name_explicit=false, @cdata=nil, @required=nil, @frozen=nil, @wrapper=nil, @namespace=nil, @accessor="networkTransId", @array=false, @blocks=[], @sought_type=:text, @attr_name="networkTransId", @name="networkTransId">, @instance=#<AuthorizeNet::API::TransactionResponse:0x00007ff79af16eb0 ...>, @default_namespace="xmlns">]>
#
我经常使用awesome_print gem或类似的东西来格式化数据结构,但在这里没有效果

是否有任何解析库/算法可以从ruby中获取类似内部转储格式的was,并以某种人性化/人性化的格式显示它

我不得不阅读源代码来了解这些类的接口,所以一些格式将是天赐良机


请。。。我的眼睛在流血。

您可以使用stdlib pretty print(
需要'pp'
)中的
pretty\u inspect
,而不是常规的
inspect
,这会增加一些格式

来自AuthorizeNet的类是巨大的,没有格式是万能的。一种更积极的方法是monkeypatch
检查那些只输出您感兴趣的字段的方法