Module: Challah::UserStatusable

Extended by:
ActiveSupport::Concern
Included in:
Userable
Defined in:
lib/challah/concerns/user/statusable.rb

Instance Method Summary collapse

Instance Method Details

#activeObject



37
38
39
# File 'lib/challah/concerns/user/statusable.rb', line 37

def active
  active?
end

#active=(enabled) ⇒ Object

Fallback to pre-enum active column (pre challah 1.4)



18
19
20
21
22
23
24
# File 'lib/challah/concerns/user/statusable.rb', line 18

def active=(enabled)
  if self.class.columns.map(&:name).include?("status")
    self.status = (!!enabled ? :active : :inactive)
  else
    write_attribute(:active, !!enabled)
  end
end

#active?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
33
34
35
# File 'lib/challah/concerns/user/statusable.rb', line 26

def active?
  # enum-based status
  if self.class.columns.map(&:name).include?("status")
    read_attribute(:status).to_s == "active"

  # support for non-enum status column (pre challah 1.4)
  else
    !!read_attribute(:active)
  end
end

#valid_session?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/challah/concerns/user/statusable.rb', line 41

def valid_session?
  active?
end