Sha256: 60ddc6c3c8a0794eb61e4bb047e0fccdf1060e85d083e3701cfca2d178aa16b9
Contents?: true
Size: 812 Bytes
Versions: 2
Compression:
Stored size: 812 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 = nil, options = {}, &block) if block options = object || {} object = yield end if object.respond_to?(:to_html) object.to_html(options) 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
html_format-0.0.11 | lib/html_format/core_ext.rb |
html_format-0.0.10 | lib/html_format/core_ext.rb |