Sha256: e078808a5f6abe4024d5737e946286068f62dd2a2c13ab699dc5f62be686505f
Contents?: true
Size: 926 Bytes
Versions: 15
Compression:
Stored size: 926 Bytes
Contents
# -*- encoding: utf-8 -*- module WatchTower module Server module Helpers module Presenters def self.included(base) base.send :include, InstanceMethods end module InstanceMethods # Define partial as a helper helpers do # Present an object # Usually called with a block, the method yields the presenter into # the block # # @param [ActiveRecord::Base] Object: The model to present # @param [Nil | Object] klass: The klass to present def present(object, klass = nil) klass ||= "::WatchTower::Server::Presenters::#{object.class.to_s.split('::').last}Presenter".constantize presenter = klass.new(object, self) yield presenter if block_given? presenter end end end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems