0.0
No commit activity in last 3 years
No release in over 3 years
Adds sex field (with helpers) to a mongoid model
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 2.0
 Project Readme

mongoid-sex readme

class Person
  include Mongoid::Document
  include Mongoid::Sex

  field :name, type: String
end
p = Person.last

p.sex
=> male

p.sex.male?
=> true

p.sex.his_her
=> "his"

"This is #{p.name}. #{p.sex.he_she.capitalize} is #{p.sex}"
=> "This is Ryan. He is male"
p = Person.last

p.sex = :male
p.sex
=> male

p.sex = 'F'
p.sex
=> female

Optional I18n:

es:
  sex:
    male: "hombre"
    he: "él"
    female: "mujer"
    she: "ella"
"#{p.name}. #{p.sex.he_she.capitalize} es un #{p.sex}"
=> "Ryan. Él es un hombre"