SimpleObjects

Simple objects for Ruby

Gem Version Build Status Code Climate Coverage Status Dependency Status

Installation

Add this line to your application's Gemfile:

gem 'simple_objects'

And require it:

require 'simple_objects'

Usage

class SuperHero
    include SimpleObjects::Base

    attribute :name, required: true, type: String
    attribute :power, required: true, type: String
    attribute :age, type: Numeric
end

SuperHero.new(name: 'Superman', power: 'Super stuff', age: 34)

SuperHero.new(name: 'Spiderman', age: 20) #=> raises RequiredMissingError

SuperHero.new(name: 'Spiderman', power: {}) #=> raises MismatchedTypeError

Contributing

Feedback and fixes are always welcome. Please make use of Issues and Pull Requests, all code should have test coverage.

Author/Contact

SimpleObjects is written and maintained by @doomspork.

License

SimpleObjects is made available under the MIT License.