Sha256: 491aef53fdebb507f80484c86af77fd0178490eed2bb7a2a2a5f70bb74cfb179

Contents?: true

Size: 1.28 KB

Versions: 14

Compression:

Stored size: 1.28 KB

Contents

module Alchemy
  module Page::PageUsers
    extend ActiveSupport::Concern

    # Returns the creator of this page.
    #
    def creator
      Alchemy.user_class.try(:find_by, {id: creator_id})
    end

    # Returns the last updater of this page.
    #
    def updater
      Alchemy.user_class.try(:find_by, {id: updater_id})
    end

    # Returns the user currently editing this page.
    #
    def locker
      Alchemy.user_class.try(:find_by, {id: locked_by})
    end

    # Returns the name of the creator of this page.
    #
    # If no creator could be found or associated user model
    # does not respond to +#name+ it returns +'unknown'+
    #
    def creator_name
      (creator && creator.try(:name)) || I18n.t('unknown')
    end

    # Returns the name of the last updater of this page.
    #
    # If no updater could be found or associated user model
    # does not respond to +#name+ it returns +'unknown'+
    #
    def updater_name
      (updater && updater.try(:name)) || I18n.t('unknown')
    end

    # Returns the name of the user currently editing this page.
    #
    # If no locker could be found or associated user model
    # does not respond to +#name+ it returns +'unknown'+
    #
    def locker_name
      (locker && locker.try(:name)) || I18n.t('unknown')
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
alchemy_cms-3.0.4 app/models/alchemy/page/page_users.rb
alchemy_cms-3.1.0.rc1 app/models/alchemy/page/page_users.rb
alchemy_cms-3.1.0.beta6 app/models/alchemy/page/page_users.rb
alchemy_cms-3.1.0.beta5 app/models/alchemy/page/page_users.rb
alchemy_cms-3.1.0.beta4 app/models/alchemy/page/page_users.rb
alchemy_cms-3.0.3 app/models/alchemy/page/page_users.rb
alchemy_cms-3.1.0.beta3 app/models/alchemy/page/page_users.rb
alchemy_cms-3.1.0.beta2 app/models/alchemy/page/page_users.rb
alchemy_cms-3.1.0.beta1 app/models/alchemy/page/page_users.rb
alchemy_cms-3.0.2 app/models/alchemy/page/page_users.rb
alchemy_cms-3.0.1 app/models/alchemy/page/page_users.rb
alchemy_cms-3.0.0 app/models/alchemy/page/page_users.rb
alchemy_cms-3.0.0.rc8 app/models/alchemy/page/page_users.rb
alchemy_cms-3.0.0.rc7 app/models/alchemy/page/page_users.rb