No commit activity in last 3 years
No release in over 3 years
Serialize hashes with ActiveModelSerializers.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 10.0
>= 0

Runtime

 Project Readme

ActiveModelSerializers::HashWrapper

Automatically create wrapper classes for Hashes so ActiveModelSerializers will serialize your hash!

Code Climate

Test Coverage

Issue Count

Build Status

Installation

Add this line to your application's Gemfile:

gem 'active_model_serializers-hash_wrapper'

And then execute:

$ bundle

Or install it yourself as:

$ gem install active_model_serializers-hash_wrapper

Usage

Let's say you have a hash, and you would like AMS to serialize it. You can create a wrapper class for your hash like so:

item_class = ActiveModelSerializers::HashWrapper.wrapper_class("Item")
wrapped_item = item_class.new(hash)

Or, for simplicity, you can do all this in one line:

wrapped_item = ActiveModelSerializers::HashWrapper.create("Item", hash)

Wrapper classes created by ActiveModelSerializers::HashWrapper pass all AMS lint tests and can safely be used.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ptrln/active_model_serializers-hash_wrapper.