Module: HtmlTo::InstanceMethods

Defined in:
lib/html_to.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



102
103
104
105
106
107
108
# File 'lib/html_to.rb', line 102

def self.included(base)
  base.attr_accessor :html_to_skip_meta_image_generate
  base.instance_eval do
    alias_method :create_meta_image!, :html_to_create_meta_image! unless method_defined? :create_meta_images!
  end
  base.after_save_commit :html_to_create_meta_image!, unless: :html_to_skip_meta_image_generate
end

Instance Method Details

#html_to_create_meta_image!Object



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/html_to.rb', line 110

def html_to_create_meta_image!
  share_images_settings = [self.class.html_to_image_settings, *self.class.html_to_image_settings.additional_images.values].flatten
  share_images_settings.each do |image_settings|
    generator_args = [
      id, self.class.name, image_settings.serializer, {
        image_name: image_settings.image_name,
        width: image_settings.width,
        height: image_settings.height,
        template: image_settings.find_template_path!
      }
    ]
    if html_to_synchronous?
      MetaImageGenerateJob.perform_now(*generator_args)
    else
      MetaImageGenerateJob.perform_later(*generator_args)
    end
  end
end