Module: LatoBlog::Post::EntityHelpers

Included in:
LatoBlog::Post
Defined in:
app/models/lato_blog/post/entity_helpers.rb

Instance Method Summary collapse

Instance Method Details

#get_category_titlesObject

This function return the list of titles of categories.



42
43
44
# File 'app/models/lato_blog/post/entity_helpers.rb', line 42

def get_category_titles
  categories.pluck(:title).to_sentence
end

#get_pretty_created_atObject

This function returns a pretty presentation of the creation date for the post.



10
11
12
# File 'app/models/lato_blog/post/entity_helpers.rb', line 10

def get_pretty_created_at
  return self.created_at.strftime('%d/%m/%Y - %H:%M')
end

#get_pretty_languageObject

This function returns a pretty presentation of the post language.



25
26
27
28
29
# File 'app/models/lato_blog/post/entity_helpers.rb', line 25

def get_pretty_language
  CONFIGS[:lato_blog][:languages].values.each do |language|
    return language[:title] if language[:identifier] === self.meta_language
  end
end

#get_pretty_publication_datetimeObject

This function returns a pretty presentation of the pubblication date for the post.



5
6
7
# File 'app/models/lato_blog/post/entity_helpers.rb', line 5

def get_pretty_publication_datetime
  return self.post_parent.publication_datetime.strftime('%d/%m/%Y - %H:%M')
end

#get_pretty_statusObject

This function returns a pretty presentation of the post status.



20
21
22
# File 'app/models/lato_blog/post/entity_helpers.rb', line 20

def get_pretty_status
  return LANGUAGES[:lato_blog][:posts_status][self.meta_status]
end

#get_pretty_updated_atObject

This function returns a pretty presentation of the update date for the post.



15
16
17
# File 'app/models/lato_blog/post/entity_helpers.rb', line 15

def get_pretty_updated_at
  return self.updated_at.strftime('%d/%m/%Y - %H:%M')
end

#get_superuser_creator_nameObject

This function returns the name of the superuser creator of the post.



32
33
34
# File 'app/models/lato_blog/post/entity_helpers.rb', line 32

def get_superuser_creator_name
  return self.superuser_creator ? self.superuser_creator.get_complete_name : 'Anonymous'
end

#get_translation_for_language(language_identifier) ⇒ Object

This function the post translation for a specific language.



37
38
39
# File 'app/models/lato_blog/post/entity_helpers.rb', line 37

def get_translation_for_language(language_identifier)
  return self.post_parent.posts.find_by(meta_language: language_identifier)
end