Module: Mongoid::Sex

Extended by:
ActiveSupport::Concern
Defined in:
lib/mongoid-sex/value.rb,
lib/mongoid-sex/version.rb,
lib/mongoid-sex/mongoid-sex.rb

Defined Under Namespace

Classes: Value

Constant Summary collapse

VERSION =
"0.0.1"

Instance Method Summary collapse

Instance Method Details

#sexObject



12
13
14
# File 'lib/mongoid-sex/mongoid-sex.rb', line 12

def sex
  Value.new(male_boolean) if !male_boolean.nil?
end

#sex=(value) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/mongoid-sex/mongoid-sex.rb', line 16

def sex=(value)
  case value.to_s.chars.first.downcase
  when 'm'
    write_attribute :male_boolean, true
  when 'f'
    write_attribute :male_boolean, false
  else
    raise 'Not a supported value for sex'
  end
rescue
  raise 'Not a supported value for sex'
end