Class: PostManager

Inherits:
Object
  • Object
show all
Defined in:
app/services/post_manager.rb

Direct Known Subclasses

ArticleHandler, BlogPostHandler, NewsHandler

Defined Under Namespace

Classes: ArticleHandler, BlogPostHandler, NewsHandler

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entity) ⇒ PostManager

Returns a new instance of PostManager.

Parameters:



3
4
5
6
# File 'app/services/post_manager.rb', line 3

def initialize(entity)
  @entity = entity
  @body   = entity.body.to_s
end

Class Method Details

.handler(entity) ⇒ Object

Parameters:



9
10
11
12
13
# File 'app/services/post_manager.rb', line 9

def self.handler(entity)
  handler_name  = "post_manager/#{entity.post_type.slug}_handler".classify
  handler_class = handler_name.safe_constantize || PostManager
  handler_class.new(entity)
end

Instance Method Details

#category_path(category) ⇒ Object

Parameters:



28
29
30
# File 'app/services/post_manager.rb', line 28

def category_path(category)
  "posts/#{category.long_slug}"
end

#edit_pathObject



23
24
25
# File 'app/services/post_manager.rb', line 23

def edit_path
  "/posts/#{@entity.id}/edit"
end

#parsed_bodyObject



15
16
17
# File 'app/services/post_manager.rb', line 15

def parsed_body
  @body.gsub(/<script/, '&lt;script')
end

#post_pathObject



19
20
21
# File 'app/services/post_manager.rb', line 19

def post_path
  "/posts/#{@entity.id}"
end