Sha256: 145a798ac45c9c79a417a98c6331e78c51af463d3c585e55021efca0d71f7e18

Contents?: true

Size: 733 Bytes

Versions: 3

Compression:

Stored size: 733 Bytes

Contents

module Workarea
  class Storefront::ShareViewModel < ApplicationViewModel
    def to
      if to_name.present?
        "#{to_name} <#{to_email}>"
      else
        to_email
      end
    end

    def from
      if from_name.present?
        "#{from_name} <#{from_email}>"
      else
        from_email
      end
    end

    def from_name
      model.from_name || options[:user].try(:name)
    end

    def from_email
      model.from_email || options[:user].try(:email)
    end

    def friendly_from
      if from_name.blank?
        from_email
      else
        from_name
      end
    end

    def friendly_to
      if to_name.present?
        "#{to_name} (#{to_email})"
      else
        to_email
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-share-1.3.1 app/view_models/workarea/storefront/share_view_model.rb
workarea-share-1.3.0 app/view_models/workarea/storefront/share_view_model.rb
workarea-share-1.2.4 app/view_models/workarea/storefront/share_view_model.rb