Module: HasMagickTitle::Base::InstanceMethods

Defined in:
lib/has_magick_title.rb

Instance Method Summary collapse

Instance Method Details

#has_magick_title?Boolean Also known as: has_image_title?

Returns:

  • (Boolean)


45
46
47
# File 'lib/has_magick_title.rb', line 45

def has_magick_title?
  !image_title.nil?
end

#magick_title_textObject



50
51
52
# File 'lib/has_magick_title.rb', line 50

def magick_title_text
  send magick_title_options[:attribute]
end

#refresh_magick_title(opts = {}) ⇒ Object



54
55
56
57
58
59
60
61
# File 'lib/has_magick_title.rb', line 54

def refresh_magick_title(opts={})
  self.image_title = build_image_title unless has_magick_title?
  if opts[:force] || (image_title.new_record? || send("#{magick_title_options[:attribute]}_changed?"))
    image_title.send(:delete_magick_title)
    image = MagickTitle::Image.create(magick_title_text, magick_title_options)
    image_title.update_attributes(image.identify.merge(:filename => image.filename))
  end                       
end