https://github.com/humawork/wardrobe
Dress up your Ruby objects with garments from Wardrobe!
https://github.com/humawork/wardrobe
attributes coercion config gem immutable ruby validation
Last synced: 10 months ago
JSON representation
Dress up your Ruby objects with garments from Wardrobe!
- Host: GitHub
- URL: https://github.com/humawork/wardrobe
- Owner: humawork
- License: mit
- Created: 2017-02-01T12:07:59.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-03T15:00:19.000Z (over 8 years ago)
- Last Synced: 2025-07-28T16:37:11.010Z (11 months ago)
- Topics: attributes, coercion, config, gem, immutable, ruby, validation
- Language: Ruby
- Homepage:
- Size: 1.89 MB
- Stars: 5
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Wardrobe
[](https://travis-ci.org/agensdev/wardrobe)
[](https://codeclimate.com/github/agensdev/wardrobe)
[](https://codeclimate.com/github/agensdev/wardrobe/coverage)
[](https://rubygems.org/gems/wardrobe)
Wardrobe is a gem that simplifies creating Ruby objects with attributes. Wardrobe bundles a multitude of plugins. See [list](#bundled-plugins) below.
## Requirements
Wardrobe requires Ruby 2.4.0 or later. Read more about why [here](#ruby-24).
JRuby should be supported once [9.2.0.0](https://github.com/jruby/jruby/milestone/53) is released
## Documentation
[Documentation for Wardrobe](https://agensdev.github.io/wardrobe/getting-started/about/)
## Installation
```
gem install wardrobe
```
## Getting started
```ruby
require 'wardrobe'
class User
include Wardrobe
attribute :name, String
end
User.new(name: 'Wardrobe User')
```
[Read more here](https://agensdev.github.io/wardrobe/getting-started/about/)
## Goals
Wardrobe should:
* be faster than Virtus
* have no dependencies (plugins may)
* not pollute the instance level with any methods other than ones prefixed with `_`
* should be immutable in the config layer allowing subclasses or singleton classes to modify the config
* be easy to extend with plugins
* simplify coercions through refinements
## Ruby 2.4
When working on the first "Proof of Concept" for Wardrobe I wanted to use refinements for coercion. This was right before Ruby 2.4 was released that added support for using Kernel#send to call a method defined in a refined class. This was needed to get my first POC working and is why Wardrobe requires ruby 2.4 or above.