Module: HtmlTo::ClassMethods

Defined in:
lib/html_to.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



79
80
81
82
83
84
# File 'lib/html_to.rb', line 79

def self.extended(base)
  class << base
    alias_method :create_meta_images!, :html_to_create_meta_images! unless method_defined? :create_meta_images!
  end
  base.cattr_accessor :html_to_image_settings
end

Instance Method Details

#html_to(serializer, options = {}, &block) ⇒ Object



90
91
92
93
94
95
96
97
98
# File 'lib/html_to.rb', line 90

def html_to(serializer, options = {}, &block)
  after_validation :html_to_mark_synchronous if options.delete(:synchronous) == true && respond_to?(:after_validation)
  after_validation :html_to_mark_skip_meta_image_generate if options.delete(:skip_auto_update) == true && respond_to?(:after_validation)

  self.html_to_image_settings = HtmlToImageSettings.new(self, serializer, options, &block)
  class_eval do
    has_one_attached options[:image_name] || html_to_image_settings.image_name
  end
end

#html_to_create_meta_images!Object



86
87
88
# File 'lib/html_to.rb', line 86

def html_to_create_meta_images!
  all.each(&:html_to_create_meta_image!)
end