Class: Pressroom::Post
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Pressroom::Post
- Includes:
- Authorable, Scoped, Sluggable
- Defined in:
- app/models/pressroom/post.rb
Constant Summary collapse
- SCHEMA_VERSION =
1- EMPTY_DOCUMENT =
{ "schema_version" => SCHEMA_VERSION, "blocks" => [] }.freeze
- EXCERPT_LENGTH =
200
Constants included from Sluggable
Constants included from Scoped
Scoped::NO_SCOPE_ID, Scoped::NO_SCOPE_TYPE
Instance Method Summary collapse
- #blocks ⇒ Object
-
#content=(value) ⇒ Object
Normalizes anything the caller hands us into a versioned document.
-
#published? ⇒ Boolean
Live to the public right now, as opposed to merely flagged published.
- #tag_names ⇒ Object
-
#tag_names=(value) ⇒ Object
Accepts an array of names or a comma separated string, and replaces the whole tag set.
Methods included from Scoped
id_for, #scope, #scope=, #scoped?, type_for
Instance Method Details
#blocks ⇒ Object
45 46 47 |
# File 'app/models/pressroom/post.rb', line 45 def blocks Array(content.is_a?(Hash) ? content["blocks"] : nil) end |
#content=(value) ⇒ Object
Normalizes anything the caller hands us into a versioned document.
41 42 43 |
# File 'app/models/pressroom/post.rb', line 41 def content=(value) super(normalize_document(value)) end |
#published? ⇒ Boolean
Live to the public right now, as opposed to merely flagged published.
61 62 63 |
# File 'app/models/pressroom/post.rb', line 61 def published? status == "published" && published_at.present? && published_at <= Time.current end |
#tag_names ⇒ Object
49 50 51 |
# File 'app/models/pressroom/post.rb', line 49 def tag_names .map(&:name) end |
#tag_names=(value) ⇒ Object
Accepts an array of names or a comma separated string, and replaces the whole tag set.
55 56 57 58 |
# File 'app/models/pressroom/post.rb', line 55 def tag_names=(value) names = value.is_a?(String) ? value.split(",") : Array(value) self. = Pressroom::Tag.for_names(names) end |