Class: Did::Action::Sit

Inherits:
Object
  • Object
show all
Defined in:
lib/did/action/sit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#start_timeObject

Returns the value of attribute start_time.



6
7
8
# File 'lib/did/action/sit.rb', line 6

def start_time
  @start_time
end

Instance Method Details

#performObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/did/action/sit.rb', line 8

def perform
  current_sitting = Sitting.find(:first, :conditions => {:current => true})

  if current_sitting && current_sitting.end_time.nil?
    current_sitting.update_attributes(:start_time => @start_time)
  else
    current_sitting.update_attributes(:current => false) if current_sitting
    Sitting.create(:start_time => @start_time, :current => true)
  end
end