BetterCase
Better Case uses refinements to implement ´===´ in core clases to enable you to use case for cool stuff.
Array use ´include?´, Symbol use ´respond_to?´ to make duck typing.
To use it simply require and add using BetterCase
on your module/class
the rest of the code should never notice the change.
Installation
$ gem install better_case
Usage
module Symbols
using BetterCase # enabled only on request
def a_method_that_duck_type object
case object
when :to_time
# do something with it
when :concat
# other stuff
end
end
def valid_option? option
case option
when [:a, :b] then true
else false
end
end
end
Road Map
Well, I coudn't find any good feature to use for Hash, so I welcome any ideas.
Contributing
- Fork it ( https://github.com/eloyesp/better_case/fork )
- 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 a new Pull Request