Class: PostManager
- Inherits:
-
Object
show all
- Defined in:
- app/services/post_manager.rb
Defined Under Namespace
Classes: ArticleHandler, BlogPostHandler, NewsHandler
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(entity, locale = I18n.locale) ⇒ PostManager
Returns a new instance of PostManager.
4
5
6
7
8
|
# File 'app/services/post_manager.rb', line 4
def initialize(entity, locale = I18n.locale)
@entity = entity
@body = entity.body.to_s
@prefix = locale.nil? ? '' : "/#{locale}"
end
|
Class Method Details
.handler(entity, locale = I18n.locale) ⇒ Object
12
13
14
15
16
|
# File 'app/services/post_manager.rb', line 12
def self.handler(entity, locale = I18n.locale)
handler_name = "post_manager/#{entity.post_type.slug}_handler".classify
handler_class = handler_name.safe_constantize || PostManager
handler_class.new(entity, locale)
end
|
Instance Method Details
#category_path(category) ⇒ Object
31
32
33
|
# File 'app/services/post_manager.rb', line 31
def category_path(category)
"#{@prefix}/posts/#{category.long_slug}"
end
|
#edit_path ⇒ Object
26
27
28
|
# File 'app/services/post_manager.rb', line 26
def edit_path
"#{@prefix}/posts/#{@entity.id}/edit"
end
|
#parsed_body ⇒ Object
18
19
20
|
# File 'app/services/post_manager.rb', line 18
def parsed_body
@body.gsub(/<script/, '<script')
end
|
#post_path ⇒ Object
22
23
24
|
# File 'app/services/post_manager.rb', line 22
def post_path
"#{@prefix}/posts/#{@entity.id}"
end
|