Module: Central::Support::StoryConcern::Callbacks

Extended by:
ActiveSupport::Concern
Defined in:
lib/central/support/concerns/story_concern/callbacks.rb

Instance Method Summary collapse

Instance Method Details

#cache_user_namesObject



40
41
42
43
44
45
46
# File 'lib/central/support/concerns/story_concern/callbacks.rb', line 40

def cache_user_names
  self.requested_by_name = requested_by.name unless requested_by.nil?
  if owned_by.present?
    self.owned_by_name     = owned_by.name
    self.owned_by_initials = owned_by.initials
  end
end

#set_accepted_atObject



31
32
33
34
35
36
37
38
# File 'lib/central/support/concerns/story_concern/callbacks.rb', line 31

def set_accepted_at
  return unless state_changed?
  return unless state == 'accepted'
  self.accepted_at = Time.current if accepted_at.nil?
  if started_at
    self.cycle_time = accepted_at - started_at
  end
end

#set_position_to_lastObject



15
16
17
18
19
20
# File 'lib/central/support/concerns/story_concern/callbacks.rb', line 15

def set_position_to_last
  return true if position
  return true unless project
  last = project.stories.order(position: :desc).first
  self.position = last ? ( last.position + 1 ) : 1
end

#set_started_atObject



22
23
24
25
26
27
28
29
# File 'lib/central/support/concerns/story_concern/callbacks.rb', line 22

def set_started_at
  return unless state_changed?
  return unless state == 'started'
  self.started_at = Time.current if started_at.nil?
  if owned_by.nil? && acting_user
    self.owned_by = acting_user
  end
end