No description, website, or topics provided.
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.gitignore
Gemfile
README.md
Rakefile
mongoid-sex.gemspec

README.md

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"