Module: Enumerize::Predicates
- Defined in:
- lib/enumerize/predicates.rb
Overview
Predicate methods.
Basic usage:
class User
extend Enumerize
enumerize :sex, in: %w(male female), predicates: true
end
user = User.new
user.male? # => false
user.female? # => false
user.sex = 'male'
user.male? # => true
user.female? # => false
Using prefix:
class User
extend Enumerize
enumerize :sex, in: %w(male female), predicates: { prefix: true }
end
user = User.new
user.sex = 'female'
user.sex_female? # => true
Use only
and except
options to specify what values create predicate methods for.
Defined Under Namespace
Classes: Builder