Class: Project
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Project
- Extended by:
- NamePartFinder
- Includes:
- AASM
- Defined in:
- app/models/project.rb
Instance Attribute Summary (collapse)
-
- (Object) cached_note_count
Returns the value of attribute cached_note_count.
Class Method Summary (collapse)
Instance Method Summary (collapse)
- - (Boolean) blocked?
- - (Object) clear_completed_at_date
- - (Object) default_context
- - (Object) hide_todos
- - (Object) name=(value)
- - (Boolean) needs_review?(current_user)
- - (Boolean) new_record_before_save?
- - (Object) note_count
- - (Object) original_default_context
- - (Object) set_completed_at_date
- - (Boolean) stalled?
-
- (Object) transition_to(candidate_state)
would prefer to call this method state=(), but that causes an endless loop as a result of acts_as_state_machine calling state=() to update the attribute.
- - (Object) unhide_todos
Methods included from NamePartFinder
Instance Attribute Details
- (Object) cached_note_count
Returns the value of attribute cached_note_count
44 45 46 |
# File 'app/models/project.rb', line 44 def cached_note_count @cached_note_count end |
Class Method Details
+ (Object) feed_options(user)
50 51 52 53 54 55 |
# File 'app/models/project.rb', line 50 def self.(user) { :title => I18n.t('models.project.feed_title'), :description => I18n.t('models.project.feed_description', :username => user.display_name) } end |
+ (Object) null_object
46 47 48 |
# File 'app/models/project.rb', line 46 def self.null_object NullProject.new end |
Instance Method Details
- (Boolean) blocked?
115 116 117 118 119 120 |
# File 'app/models/project.rb', line 115 def blocked? ## mutually exclusive for stalled and blocked # blocked is uncompleted project with deferred or pending todos, but no next actions return false if self.completed? return !self.todos.deferred_or_blocked.empty? && self.todos.not_deferred_or_blocked.empty? end |
- (Object) clear_completed_at_date
79 80 81 |
# File 'app/models/project.rb', line 79 def clear_completed_at_date self.completed_at = nil end |
- (Object) default_context
91 92 93 |
# File 'app/models/project.rb', line 91 def default_context original_default_context.nil? ? Context.null_object : original_default_context end |
- (Object) hide_todos
57 58 59 60 61 62 63 64 |
# File 'app/models/project.rb', line 57 def hide_todos todos.each do |t| unless t.completed? || t.deferred? t.hide! t.save end end end |
- (Object) name=(value)
129 130 131 |
# File 'app/models/project.rb', line 129 def name=(value) self[:name] = value.gsub(/\s{2,}/, " ").strip end |
- (Boolean) needs_review?(current_user)
110 111 112 113 |
# File 'app/models/project.rb', line 110 def needs_review?(current_user) return active? && ( last_reviewed.nil? || (last_reviewed < current_user.time - current_user.prefs.review_period.days)) end |
- (Boolean) new_record_before_save?
133 134 135 |
# File 'app/models/project.rb', line 133 def new_record_before_save? @new_record_before_save end |
- (Object) note_count
83 84 85 86 87 |
# File 'app/models/project.rb', line 83 def note_count # TODO: test this for eager and not eager loading!!! return 0 if notes.size == 0 cached_note_count || notes.count end |
- (Object) original_default_context
89 |
# File 'app/models/project.rb', line 89 alias_method :original_default_context, :default_context |
- (Object) set_completed_at_date
75 76 77 |
# File 'app/models/project.rb', line 75 def set_completed_at_date self.completed_at = Time.zone.now end |
- (Boolean) stalled?
122 123 124 125 126 |
# File 'app/models/project.rb', line 122 def stalled? # stalled is active/hidden project with no active todos return false if self.completed? return self.todos.deferred_or_blocked.empty? && self.todos.not_deferred_or_blocked.empty? end |
- (Object) transition_to(candidate_state)
would prefer to call this method state=(), but that causes an endless loop as a result of acts_as_state_machine calling state=() to update the attribute
97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'app/models/project.rb', line 97 def transition_to(candidate_state) case candidate_state.to_sym when aasm_current_state return when :hidden hide! when :active activate! when :completed complete! end end |
- (Object) unhide_todos
66 67 68 69 70 71 72 73 |
# File 'app/models/project.rb', line 66 def unhide_todos todos.each do |t| if t.project_hidden? t.unhide! t.save end end end |