Sha256: 2215a03c1237e658f888e13f421890e08515180da91b8d469d5e97071a6eaf47
Contents?: true
Size: 706 Bytes
Versions: 7
Compression:
Stored size: 706 Bytes
Contents
require 'active_support/core_ext/kernel/concern' module HtmlFormat concern :ActiveRecord do class_methods do def to_html(**options) HtmlFormat.generate(all.collect(&:attributes), options) end end def to_html(**options) HtmlFormat.generate(attributes, options) end end end Kernel.class_eval do private def html_format(object, **options) if object.respond_to?(:to_html) object.to_html else HtmlFormat.generate(object, options) end end end [Array, Symbol, String, Hash, Numeric, TrueClass, FalseClass, NilClass].each do |e| e.class_eval do def to_html(**options) HtmlFormat.generate(self, options) end end end
Version data entries
7 entries across 7 versions & 1 rubygems