Class: Avatar::Source::FileColumnSource
- Inherits:
-
Object
- Object
- Avatar::Source::FileColumnSource
- Includes:
- AbstractSource, FileColumnHelper
- Defined in:
- lib/avatar/source/file_column_source.rb
Overview
For use with the FileColumn Rails plugin.
Instance Attribute Summary collapse
-
#default_field ⇒ Object
Returns the value of attribute default_field.
Instance Method Summary collapse
-
#avatar_url_for(person, options = {}) ⇒ Object
Returns nil if person is nil; otherwise, returns the (possibly nil) result of
url_for_image_column
, passing in all ofoptions
except :file_column_field. -
#initialize(default_field = :avatar) ⇒ FileColumnSource
constructor
A new instance of FileColumnSource.
- #parse_options(person, options) ⇒ Object
Constructor Details
#initialize(default_field = :avatar) ⇒ FileColumnSource
Returns a new instance of FileColumnSource.
13 14 15 16 |
# 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 |
Instance Attribute Details
#default_field ⇒ Object
Returns the value of attribute default_field.
11 12 13 |
# File 'lib/avatar/source/file_column_source.rb', line 11 def default_field @default_field end |
Instance Method Details
#avatar_url_for(person, options = {}) ⇒ Object
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 withinperson
; 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)
25 26 27 28 29 30 31 32 |
# File 'lib/avatar/source/file_column_source.rb', line 25 def avatar_url_for(person, = {}) return nil if person.nil? = (person, ) field = .delete(:file_column_field) || default_field return nil if field.nil? || person.send(field).nil? = [:file_column_version] || url_for_image_column(person, field, ) end |
#parse_options(person, options) ⇒ Object
34 35 36 |
# File 'lib/avatar/source/file_column_source.rb', line 34 def (person, ) end |