Scottie

Adds accessors (using type_constraints) to Module class.

Build Status

Synopsis

require 'scottie'
require 'type_constraints'

TypeConstraints.setup do
  subtype :NotNgWord, :String do
    constraint -> v { v !~ // }
  end
end

class Person
  has name: :NotNgWord, twitter_acount: :String
end

# ok
person = Person.new
person.name = "ひさいち"
person.twitter_acount = "hisaichi5518"

# throw exception
# person.name = "悪魔ちゃん"
# person.twitter_acount = :hisaichi5518

# ok
p person.name #=> "ひさいち"
p person.twitter_acount #=> "hisaichi5518"

Installation

Add this line to your application's Gemfile:

gem 'scottie'

And then execute:

$ bundle

Or install it yourself as:

$ gem install scottie

See also

Contributing

  1. Fork it ( https://github.com/hisaichi5518/scottie/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