Module: SentientModel::ClassMethods

Defined in:
lib/sentient_model.rb

Instance Method Summary collapse

Instance Method Details

#currentObject



15
16
17
# File 'lib/sentient_model.rb', line 15

def current
  Thread.current[sentient_model_name]
end

#current=(m) ⇒ Object



19
20
21
22
23
24
# File 'lib/sentient_model.rb', line 19

def current=(m)
  unless (m.is_a?(self) || m.nil?)
    raise(ArgumentError, "Expected an object of class '#{self}', got #{m.inspect}")
  end
  Thread.current[sentient_model_name] = m
end

#has_current?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/sentient_model.rb', line 26

def has_current?
  !self.current.nil?
end