Sha256: 7a9748712e317860bc34e33e1e83955d0bbc9147eaad205423b767aac8615fb9
Contents?: true
Size: 667 Bytes
Versions: 2
Compression:
Stored size: 667 Bytes
Contents
module Presenters module Helper def present(*args, &block) Helper.present(*args, &block) end def present_each(instances, class_type = nil, &block) instances.each do |instance| present(instance, class_type, &block) end end def presenters(instances, class_type = nil) instances.map do |instance| present(instance, class_type) end end def self.present(instance, class_type = nil, &block) class_type = class_type || Object.const_get("#{instance.class}Presenter") presenter = class_type.new(instance) yield(presenter) if block_given? return presenter end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
presenters-0.3.0 | lib/presenters/helper.rb |
presenters-0.2.1 | lib/presenters/helper.rb |