vendor/plugins/rust-file_column/lib/file_column_helper.rb
# Same as +url_for_file_colum+ but allows you to access different versions
# of the image that have been processed by RMagick.
#
# If your +options+ parameter is non-nil this will
# access a different version of an image that will be produced by
# RMagick. You can use the following types for +options+:
#
# * a <tt>:symbol</tt> will select a version defined in the model
#   via FileColumn::Magick's <tt>:versions</tt> feature.
# * a <tt>geometry_string</tt> will dynamically create an
#   image resized as specified by <tt>geometry_string</tt>. The image will
#   be stored so that it does not have to be recomputed the next time the
#   same version string is used.
# * <tt>some_hash</tt> will dynamically create an image
#   that is created according to the options in <tt>some_hash</tt>. This
#   accepts exactly the same options as Magick's version feature.
#
# The version produced by RMagick will be stored in a special sub-directory.
# The directory's name will be derived from the options you specified
# (via a hash function) but if you want
# to set it yourself, you can use the <tt>:name => name</tt> option.
#
# Examples:
#
#    <%= url_for_image_column @entry, "image", "640x480" %>
#
# will produce an URL like this
#
#    /entry/image/42/bdn19n/filename.jpg
#    # "640x480".hash.abs.to_s(36) == "bdn19n"
#
# and
#
#    <%= url_for_image_column @entry, "image", 
#       :size => "50x50", :crop => "1:1", :name => "thumb" %>
#
# will produce something like this:
#
#    /entry/image/42/thumb/filename.jpg
#
# Hint: If you are using the same geometry string / options hash multiple times, you should
# define it in a helper to stay with DRY. Another option is to define it in the model via
# FileColumn::Magick's <tt>:versions</tt> feature and then refer to it via a symbol.
#
# The URL produced by this method is relative to your application's root URL,
# although it will start with a slash.
# If you pass this URL to rails' +image_tag+ helper, it will be converted to an
# absolute URL automatically.
# If there is currently no image uploaded, or there is a problem while loading
# the image this method will return +nil+.
Same as +url_for_file_colum+ but allows you to access different versions
of the image that have been processed by RMagick.

If your +options+ parameter is non-nil this will
access a different version of an image that will be produced by
RMagick. You can use the following types for +options+.

a :symbol will select a version defined in the model
via FileColumn::Magick's :versions feature.
a geometry_string will dynamically create an
image resized as specified by geometry_string. The image will
be stored so that it does not have to be recomputed the next time the
same version string is used.
some_hash will dynamically create an image
that is created according to the options in some_hash. This
accepts exactly the same options as Magick's version feature.

The version produced by RMagick will be stored in a special sub-directory.
The directory's name will be derived from the options you specified
(via a hash function) but if you want
to set it yourself, you can use the :name => name option.





will produce an URL like this



and



will produce something like this.



If you are using the same geometry string / options hash multiple times, you should
define it in a helper to stay with DRY. Another option is to define it in the model via
FileColumn::Magick's :versions feature and then refer to it via a symbol.

The URL produced by this method is relative to your application's root URL,
although it will start with a slash.
If you pass this URL to rails' +image_tag+ helper, it will be converted to an
absolute URL automatically.
If there is currently no image uploaded, or there is a problem while loading
the image this method will return +nil+.
Same as + url_for_file_colum + but allows you to access different versions of the image that have been processed by RMagick . If your + options + parameter is non - nil this will access a different version of an image that will be produced by RMagick . You can use the following types for + options + . a : symbol will select a version defined in the model via FileColumn :: Magick ' s : versions feature . a geometry_string will dynamically create an image resized as specified by geometry_string . The image will be stored so that it does not have to be recomputed the next time the same version string is used . some_hash will dynamically create an image that is created according to the options in some_hash . This accepts exactly the same options as Magick ' s version feature . The version produced by RMagick will be stored in a special sub - directory . The directory ' s name will be derived from the options you specified ( via a hash function ) but if you want to set it yourself you can use the : name = > name option . will produce an URL like this and will produce something like this . If you are using the same geometry string / options hash multiple times you should define it in a helper to stay with DRY . Another option is to define it in the model via FileColumn :: Magick ' s : versions feature and then refer to it via a symbol . The URL produced by this method is relative to your application ' s root URL although it will start with a slash . If you pass this URL to rails ' + image_tag + helper it will be converted to an absolute URL automatically . If there is currently no image uploaded or there is a problem while loading the image this method will return + nil + .
def url_for_image_column(object, method, options=nil)
    case object
    when String, Symbol
      object = instance_variable_get("@#{object.to_s}")
    end
    subdir = nil
    if options
      subdir = object.send("#{method}_state").create_magick_version_if_needed(options)
    end
    if subdir.nil?
      nil
    else
      url_for_file_column(object, method, subdir)
    end
  end
def url_for_image_column ( object , method , options = nil ) case object when String , Symbol object = instance_variable_get ( "@#{object.to_s}" ) end subdir = nil if options subdir = object . send ( "#{method}_state" ) . create_magick_version_if_needed ( options ) end if subdir . nil? nil else url_for_file_column ( object , method , subdir ) end end
Same as +url_for_file_colum+ but allows you to access different versions
of the image that have been processed by RMagick.
Same as + url_for_file_colum + but allows you to access different versions of the image that have been processed by RMagick .
object
<not_specific>
method
<not_specific>
options
<not_specific>