Sha256: 1bf665d6f2d1841bed260c87ab6dc47c36ee8309a9e3736d3302a0af1581d96d
Contents?: true
Size: 678 Bytes
Versions: 1
Compression:
Stored size: 678 Bytes
Contents
module ActionPresenter module ViewHelper extend ActiveSupport::Concern included do helper_method :present end def present(object, klass = nil) klass ||= presenter_name object presenter = klass.new(object, view_context) return yield presenter if block_given? presenter end private def presenter_name(scope) "#{klass_name(scope)}Presenter".constantize end def klass_name(scope) return scope.class.to_s unless scope.is_a? Array return scope.first.class.to_s if scope.length == 1 scope.map do |s| s.is_a?(Symbol) ? s.capitalize : s.class end.join('::') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
action_presenter-1.1.1 | lib/action_presenter/view_helper.rb |