Module: ActsAsLiving::MethodsDefiner::InstanceMethods

Defined in:
lib/acts_as_living/methods_definer.rb

Instance Method Summary collapse

Instance Method Details

#dead?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/acts_as_living/methods_definer.rb', line 59

def dead?
  self.class.death == stage
end

#dead_or_dying?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/acts_as_living/methods_definer.rb', line 63

def dead_or_dying?
  dead? || dying?
end

#dying?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/acts_as_living/methods_definer.rb', line 51

def dying?
  self.class.dying?(stage)
end

#first_stage?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/acts_as_living/methods_definer.rb', line 55

def first_stage?
  self.class.first_stage?(stage)
end

#klass_phases_for(stage) ⇒ Object



71
72
73
# File 'lib/acts_as_living/methods_definer.rb', line 71

def klass_phases_for(stage)
  self.class.phases_for(stage)
end

#klass_phases_with_rangesObject



67
68
69
# File 'lib/acts_as_living/methods_definer.rb', line 67

def klass_phases_with_ranges
  self.class.phases_with_ranges
end

#klass_stagesObject



75
76
77
# File 'lib/acts_as_living/methods_definer.rb', line 75

def klass_stages
  self.class.stages
end

#locked?(&block) ⇒ Boolean

Returns:

  • (Boolean)


79
80
81
82
83
# File 'lib/acts_as_living/methods_definer.rb', line 79

def locked?(&block)
  return unless block

  @locked_on.to_set.intersect? [stage, stage_was].to_set
end

#next_stageObject



35
36
37
# File 'lib/acts_as_living/methods_definer.rb', line 35

def next_stage
  stage_after(stage) if stage
end

#phase_changed?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/acts_as_living/methods_definer.rb', line 89

def phase_changed?
  klass_phases_for(stage) != klass_phases_for(stage_was)
end

#phasesObject



85
86
87
# File 'lib/acts_as_living/methods_definer.rb', line 85

def phases
  klass_phases_for(stage)
end

#phases_endedObject



97
98
99
# File 'lib/acts_as_living/methods_definer.rb', line 97

def phases_ended
  klass_phases_for(stage_was) - klass_phases_for(stage)
end

#phases_startedObject



93
94
95
# File 'lib/acts_as_living/methods_definer.rb', line 93

def phases_started
  klass_phases_for(stage) - klass_phases_for(stage_was)
end

#previous_stageObject



47
48
49
# File 'lib/acts_as_living/methods_definer.rb', line 47

def previous_stage
  stage_before(stage)
end

#stage_after(stage) ⇒ Object



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

def stage_after(stage)
  self.class.stage_after(stage)
end

#stage_before(stage) ⇒ Object



23
24
25
# File 'lib/acts_as_living/methods_definer.rb', line 23

def stage_before(stage)
  self.class.stage_before(stage)
end

#stagesObject



19
20
21
# File 'lib/acts_as_living/methods_definer.rb', line 19

def stages
  self.class.stages
end

#to_next_stageObject



27
28
29
# File 'lib/acts_as_living/methods_definer.rb', line 27

def to_next_stage
  update(stage: next_stage)
end

#to_next_stage!Object



31
32
33
# File 'lib/acts_as_living/methods_definer.rb', line 31

def to_next_stage!
  update!(stage: next_stage)
end

#to_previous_stageObject



39
40
41
# File 'lib/acts_as_living/methods_definer.rb', line 39

def to_previous_stage
  update(stage: previous_stage)
end

#to_previous_stage!Object



43
44
45
# File 'lib/acts_as_living/methods_definer.rb', line 43

def to_previous_stage!
  update!(stage: previous_stage)
end