# This is an alternative example of welcome_page.rb using https://github.com/maxim/portrayal # Assuming that ApplicationStruct has `extend Portrayal`. # In this one I also do an example definition of ActivityItem class. class WelcomePage < ApplicationStruct def self.from_user(user) new \ greeting: "Good #{user.time_of_day}, #{user.name}", recent_activity: ActivityItem.from_user(user), support_email: Rails.configuration.app.support_email end keyword :greeting keyword :support_email keyword :recent_activity, defines: 'ActivityItem' do def self.from_user(user) user.events.last(3).map { |event| new(name: event.name, description: event.description) } end keyword :name keyword :description end end