Add a Sidebar class to represent the side bar

Start using it throughout the rest of the app instead of the various
instance variables
This commit is contained in:
Matt Rogers 2014-09-14 21:47:14 -05:00
parent 2883d1b7f4
commit 8d24f5105a
5 changed files with 66 additions and 17 deletions

29
app/models/sidebar.rb Normal file
View file

@ -0,0 +1,29 @@
class Sidebar
attr_reader :contexts, :projects
def initialize(user)
user = user
@contexts = user.contexts
@projects = user.projects
end
def active_contexts
@active_contexts ||= contexts.active
end
def hidden_contexts
@hidden_contexts ||= contexts.hidden
end
def active_projects
@active_projects ||= projects.active
end
def hidden_projects
@hidden_projects ||= projects.hidden
end
def completed_projects
@completed_projects ||= projects.completed
end
end