PikoModel
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
= Config.new a: "value", "b.c": false
.valid? #=> true
.fetch("a") #=> "value"
baz = Config.new ENV.to_h
Versioning
See semver.org
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request