app/presenters/profile_presenter.rb in woople-theme-0.6.9 vs app/presenters/profile_presenter.rb in woople-theme-0.6.10
- old
+ new
@@ -1,9 +1,30 @@
-require 'delegate'
+require 'explicit_delegator'
-class ProfilePresenter < SimpleDelegator
- def each(*)
- super do |e|
- yield ThemePresentation.wrap(e, ProfilePresenter)
+class ProfilePresenter < ExplicitDelegator
+ DEFAULT_IMAGE = 'woople-theme/missing-profile.png'
+ MISSING_WOOPLE_IMAGE = '/assets/retina_thumb/missing.png'
+
+ enforce_definitions :image, :sections
+
+ def image
+ normalized(profile.image)
+ end
+
+ def sections
+ @sections ||= ThemePresentation.wrap_collection(profile.sections, ProfileSectionPresenter)
+ end
+
+ private
+
+ def profile
+ __getobj__
+ end
+
+ def normalized(image)
+ if image.nil? || image == MISSING_WOOPLE_IMAGE
+ DEFAULT_IMAGE
+ else
+ image
end
end
end