Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 17 days 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 (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-03T15:00:19.000Z (over 7 years ago)
- Last Synced: 2024-11-20T14:06:32.131Z (about 1 month ago)
- Topics: attributes, coercion, config, gem, immutable, ruby, validation
- Language: Ruby
- Homepage:
- Size: 1.89 MB
- Stars: 5
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Wardrobe
[![Build Status](https://travis-ci.org/agensdev/wardrobe.svg?branch=master)](https://travis-ci.org/agensdev/wardrobe)
[![Code Climate](https://codeclimate.com/github/agensdev/wardrobe.svg)](https://codeclimate.com/github/agensdev/wardrobe)
[![Test Coverage](https://codeclimate.com/github/agensdev/wardrobe/badges/coverage.svg)](https://codeclimate.com/github/agensdev/wardrobe/coverage)
[![Gem Version](https://badge.fury.io/rb/wardrobe.svg)](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
endUser.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.