Let's say I have some active resource object fetched as the following:
x = Resource.find(some_id)
And x in the remote server has some field h
as a complex nested hashes which is represented here as nested active resource objects, but then accessing it is a tedious task, so is it possible to convert h
to hash? I can just make another call Resource.get(some_id) and the result will be one big hash, but this is risky as the resource -theoretically- may have changed between subsequent calls, so is there a way to convert active resource object to hash ?
Edit
For more clarification, Suppose that some invoice record r[id=some_id] has attribute extras
, which is a hash with the value: {:x=>1, :y=>2, :z=>{:a=>1, :b=>2}}
Then when fetching this record through active resource, we get the following result for extras field, -extracted from the response-:
"extras"=>
#<App::Invoice::Extras:0x00000008202cb0
@attributes=
{"x"=>1,
"y"=>2,
"z"=>
#<App::Invoice::Extras::Z:0x00000008201978
@attributes={"a"=>1, "b"=>2},
@persisted=true,
@prefix_options={}>},
@persisted=true,
@prefix_options={}>,
Then how to convert this extras field to a ruby hash ?