https://github.com/operators-rb/operators-serializer
You don’t need Active Model Serializers
https://github.com/operators-rb/operators-serializer
json operators serializer
Last synced: 6 months ago
JSON representation
You don’t need Active Model Serializers
- Host: GitHub
- URL: https://github.com/operators-rb/operators-serializer
- Owner: operators-rb
- License: mit
- Created: 2017-04-25T09:00:31.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-11T08:50:45.000Z (over 8 years ago)
- Last Synced: 2024-08-01T22:49:29.754Z (about 1 year ago)
- Topics: json, operators, serializer
- Language: Ruby
- Homepage:
- Size: 14.6 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Operators::Serializer
[](https://codeclimate.com/github/operators-rb/operators-serializer)
[](https://circleci.com/gh/operators-rb/operators-serializer)The simplest serialization ever.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'operators-serializer'
```## Usage
```ruby
class UserSerializer < Operators::Serializer
def as_json
{
id: id,
name: name,
email: email
}
end
end
```**Usage in Rails controllers**
```ruby
class UsersController < ApplicationController
def index
@users = UserSerializer.serialize_collection(User.all)
enddef show
@user = UserSerializer.new(User.find_by(id: params[:id]))
end
end
```## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/operators-rb/operators-serializer.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).