diaspora/app/presenters/base_presenter.rb
Florian Staudacher 2572fb77fc * refactored text direction detector into helper (also for handlebars)
* added handlebars helper for markdown formatting
* finished port of profile sidebar view to handlebars template
* people_controller refactoring
2014-09-15 01:37:23 +02:00

29 lines
586 B
Ruby

class BasePresenter
attr_reader :current_user
class << self
def new(*args)
return NilPresenter.new if args[0].nil?
super *args
end
def as_collection(collection, method=:as_json, *args)
collection.map{|object| self.new(object, *args).send(method) }
end
end
def initialize(presentable, curr_user=nil)
@presentable = presentable
@current_user = curr_user
end
def method_missing(method, *args)
@presentable.public_send(method, *args)
end
class NilPresenter
def method_missing(method, *args)
nil
end
end
end