Module: LatoBlog::Post::EntityHelpers
- Included in:
- LatoBlog::Post
- Defined in:
- app/models/lato_blog/post/entity_helpers.rb
Instance Method Summary collapse
-
#get_category_titles ⇒ Object
This function return the list of titles of categories.
-
#get_pretty_created_at ⇒ Object
This function returns a pretty presentation of the creation date for the post.
-
#get_pretty_language ⇒ Object
This function returns a pretty presentation of the post language.
-
#get_pretty_publication_datetime ⇒ Object
This function returns a pretty presentation of the pubblication date for the post.
-
#get_pretty_status ⇒ Object
This function returns a pretty presentation of the post status.
-
#get_pretty_updated_at ⇒ Object
This function returns a pretty presentation of the update date for the post.
-
#get_superuser_creator_name ⇒ Object
This function returns the name of the superuser creator of the post.
-
#get_translation_for_language(language_identifier) ⇒ Object
This function the post translation for a specific language.
Instance Method Details
#get_category_titles ⇒ Object
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_at ⇒ Object
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_language ⇒ Object
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. end end |
#get_pretty_publication_datetime ⇒ Object
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_status ⇒ Object
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.] end |
#get_pretty_updated_at ⇒ Object
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_name ⇒ Object
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 |