class Avatar::Source::FileColumnSource

For use with the FileColumn Rails plugin.

Attributes

default_field[RW]

Public Instance Methods

avatar_url_for(person, options = {}) click to toggle source

Returns nil if person is nil; otherwise, returns the (possibly nil) result of url_for_image_column, passing in all of options except :file_column_field. Options:

  • :file_column_field - the image file column within person; by default, :avatar

  • :file_column_version - one of the versions of the file_column; no default

If :file_column_version is not specified, all other options are passed to url_for_image_column as options (see FileColumnHelper)

# File lib/avatar/source/file_column_source.rb, line 25
def avatar_url_for(person, options = {})
  return nil if person.nil?
  options = parse_options(person, options)
  field = options.delete(:file_column_field) || default_field
  return nil if field.nil? || person.send(field).nil?
  options = options[:file_column_version] || options
  url_for_image_column(person, field, options)
end
parse_options(person, options) click to toggle source
# File lib/avatar/source/file_column_source.rb, line 34
def parse_options(person, options)
  options
end

Public Class Methods

new(default_field = :avatar) click to toggle source
# File lib/avatar/source/file_column_source.rb, line 13
def initialize(default_field = :avatar)
  raise ArgumentError.new('default_field cannot be nil') if default_field.nil?
  @default_field = default_field
end