Class: Decidim::Blogs::PostType

Inherits:
Api::Types::BaseObject
  • Object
show all
Defined in:
lib/decidim/api/post_type.rb

Overview

This type represents a Post.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.authorized?(object, context) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/decidim/api/post_type.rb', line 27

def self.authorized?(object, context)
  context[:post] = object

  chain = [
    allowed_to?(:read, :blogpost, object, context),
    !object.hidden?
  ].all?

  super && chain
rescue Decidim::PermissionAction::PermissionNotSetError
  false
end

Instance Method Details

#urlObject



23
24
25
# File 'lib/decidim/api/post_type.rb', line 23

def url
  Decidim::ResourceLocatorPresenter.new(object).url
end