I am using AMS to comply with an older API and attempting to include a prefix on each attribute.
Suppose i have this serializer:
InvoiceSerializer.new(invoice).serializable_hash
=> {
:id=>662473,
:number=>"3817",
:created_at=>Tue, 27 Jan 2015 14:55:51 PST -08:00,
:updated_at=>Tue, 27 Jan 2015 14:56:20 PST -08:00,
:date=>Tue, 27 Jan 2015,
:subtotal=>#<BigDecimal:7fa89e051380,'0.1E3',9(18)>,
:total=>#<BigDecimal:7fa89e050f70,'0.1095E3',18(18)>,
:tax=>#<BigDecimal:7fa89e050d40,'0.95E1',18(18)>,
:verified_paid=>false,
:tech_marked_paid=>true,
:ticket_id=>11111
}
and would like the output to be:
InvoiceSerializer.new(invoice).serializable_hash
=> {
:invoice_id=>662473,
:invoice_number=>"3817",
:invoice_created_at=>Tue, 27 Jan 2015 14:55:51 PST -08:00,
:invoice_updated_at=>Tue, 27 Jan 2015 14:56:20 PST -08:00,
:invoice_date=>Tue, 27 Jan 2015,
:invoice_subtotal=>#<BigDecimal:7fa89e051380,'0.1E3',9(18)>,
:invoice_total=>#<BigDecimal:7fa89e050f70,'0.1095E3',18(18)>,
:invoice_tax=>#<BigDecimal:7fa89e050d40,'0.95E1',18(18)>,
:invoice_verified_paid=>false,
:invoice_tech_marked_paid=>true,
:invoice_ticket_id=>11111
}
I would prefer to not metaprogram a solution as other people will be using this and I don't want them to hate me.