16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/has_magick_title.rb', line 16
def has_magick_title(attribute=:title, options={})
include InstanceMethods
cattr_accessor :magick_title_options
if attribute.is_a? Hash
options = attribute
attribute = :title
end
if options.is_a? Symbol
self.magick_title_options = MagickTitle.styles[options]
elsif options.is_a? Hash
self.magick_title_options = MagickTitle.options.merge(options)
else
raise ArgumentError, "has_magick_title options must be a Symbol or Hash"
end
self.magick_title_options.merge!(:attribute => attribute)
has_one :image_title, :as => :imagable, :autosave => true, :dependent => :destroy
before_save :refresh_magick_title
end
|