In short, I want to mass assign a PORO with no database with like 100 attr_accessors with the attributes of a Rails object. The point of this is to expose an object over the API that is not an ActiveRecord Object and this API is being used internally right now and is not separated over a service. What can be done?
Assume we have a database-backed
Database::Apple class with attributes. I can get them all in a hash using:
Say the PORO is called
If I initialize an
API::Apple, how can I mass assign all of its
attr_accessors with the attributes of the database-backed
Apple. Is there an easy way to do this? Does something like this exist?
Database::Apple.new.attributes = API::Apple.first.attributes?