PikoModel

Gem Version Code Climate Dependency Status

Simple model which can be initialized from Hash. It is possible to define default values and check if all reqired fields are set.

Installation

Add this line to your application's Gemfile:

gem 'piko_model'

And then execute:

$ bundle

Or install it yourself as:

$ gem install piko_model

Usage

require "piko_model"

class Config < PikoModel::Model
  field "a"
  field "b.c", default: true
end

foo = Config.new
foo.valid? #=> false
foo.missing_fields #=> ["a"]
foo["b.c"] #=> true

bar = Config.new a: "value", "b.c": false
bar.valid? #=> true
bar.fetch("a") #=> "value"

baz = Config.new ENV.to_h

Versioning

See semver.org

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request