class ApplicationController < ActiveSomething
helper_method :intranet
def intranet
@intranet ||= Intranet.new(current_user)
end
end
class DashboardController
helper_method :dashboard
def dashboard
@dashboard ||= intranet.dashboard
end
def show
@visits = dashboard.visits.paginate ...
end
end
class Intranet
def dashboard; @dashboard ||= Dashboard.new
end
class Dashboard
def stats
@stats ||= DashboardStats.new
end
end
class FilesController < ApplicationController
def new
@form_model = intranet.files.form
end
end
class Intranet
def initialize(user)
@employee = user
end
def files
@files ||= if user.is_a?(Admin)
FilesManager.new
else
FilesViewer.new
end
end
end
class FilesViewer
def files_list
end
end
class FilesBrowser < FilesViewer
def upload_file(file)
end
def remove_file(filename)
end
end