Class: Avatar::Source::Wrapper::AbstractSourceWrapper
- Inherits:
-
Object
- Object
- Avatar::Source::Wrapper::AbstractSourceWrapper
- Includes:
- AbstractSource
- Defined in:
- lib/avatar/source/wrapper/abstract_source_wrapper.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#underlying_source ⇒ Object
readonly
Returns the value of attribute underlying_source.
Instance Method Summary collapse
-
#avatar_url_for(person, options = {}) ⇒ Object
Return nil if the underlying_source does; otherwise, calls
wrap
, passing the returned URL and the person and options passed. -
#initialize(underlying_source) ⇒ AbstractSourceWrapper
constructor
Create a new Wrapper.
-
#wrap(url, person, options) ⇒ Object
Apply appropriate wrapping of the
url
returned byunderlying_source
.
Constructor Details
#initialize(underlying_source) ⇒ AbstractSourceWrapper
Create a new Wrapper
12 13 14 15 |
# File 'lib/avatar/source/wrapper/abstract_source_wrapper.rb', line 12 def initialize() raise ArgumentError.new("underlying_source must be Source") unless .kind_of?(Avatar::Source::AbstractSource) @underlying_source = end |
Instance Attribute Details
#underlying_source ⇒ Object (readonly)
Returns the value of attribute underlying_source.
9 10 11 |
# File 'lib/avatar/source/wrapper/abstract_source_wrapper.rb', line 9 def @underlying_source end |
Instance Method Details
#avatar_url_for(person, options = {}) ⇒ Object
Return nil if the underlying_source does; otherwise, calls wrap
, passing the returned URL and the person and options passed.
19 20 21 22 |
# File 'lib/avatar/source/wrapper/abstract_source_wrapper.rb', line 19 def avatar_url_for(person, = {}) url = @underlying_source.avatar_url_for(person, ) url.nil? ? nil : wrap(url, person, ) end |
#wrap(url, person, options) ⇒ Object
Apply appropriate wrapping of the url
returned by underlying_source
. Will never be called with a nil url
.
26 27 28 |
# File 'lib/avatar/source/wrapper/abstract_source_wrapper.rb', line 26 def wrap(url, person, ) raise NotImplementedError('subclasses must override wrap(url, person, options)') end |