Sha256: 7d3515b960bfe649873d07117f83eaae47730900129969b6f518917bc7b434d7
Contents?: true
Size: 984 Bytes
Versions: 3
Compression:
Stored size: 984 Bytes
Contents
require 'meta_presenter/builder' require 'active_support/rescuable' module MetaPresenter # Including this module in your controller will give # your views access to a `presenter` method that # delegates to controller methods # # class ApplicationController < ActionController::Base # include MetaPresenter::Base # end # # class ApplicationMailer < ActionMailer::Base # include MetaPresenter::Base # end # module Helpers def self.included(base) base.instance_eval do # Sets up the `presenter.` method as helper within your views # If you want to customize this for yourself just alias_method it helper_method :presenter end end private # Initialize presenter with the current controller def presenter @presenter ||= begin controller = self klass = MetaPresenter::Builder.new(controller, action_name).presenter_class klass.new(controller) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
meta_presenter-2.0.0 | lib/meta_presenter/helpers.rb |
meta_presenter-1.0.1 | lib/meta_presenter/helpers.rb |
meta_presenter-1.0.0 | lib/meta_presenter/helpers.rb |