Skip to content
This repository has been archived by the owner on Oct 29, 2022. It is now read-only.

eloyesp/validated_accessors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ValidatedAccessors Gem Version Build Status Code Climate Dependency Status

Attribute accessors with validation options so you notice when something is wrong earlier.

class Foo
  extend ValidatedAccessors

  validated_accessor :bar, valid: [:foo, :bar]

  # a transformation can be applied to the accessor for consistency

  validated_accessor(:age, valid: (18..100)) { |a| a.to_i }
end

foo = Foo.new
foo.bar = :foo # => error
foo.age = '24'
foo.age # => 24

And you can read the docs.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/validated_accessors/fork )
  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 a new Pull Request

About

Simple validated accessors for your simple classes.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages