Class: ContentBlockTools::ContentBlock
- Inherits:
-
Data
- Object
- Data
- ContentBlockTools::ContentBlock
- Defined in:
- lib/content_block_tools/content_block.rb
Overview
Defines a Content Block
Constant Summary collapse
- CONTENT_PRESENTERS =
A lookup of presenters for particular content block types
{ "content_block_email_address" => ContentBlockTools::Presenters::EmailAddressPresenter, }.freeze
Instance Attribute Summary collapse
-
#content_id ⇒ String
readonly
The content UUID for a block.
-
#details ⇒ Hash
readonly
A hash that contains the details of the content block.
-
#document_type ⇒ String
readonly
The document type of the content block - this will be used to work out which Presenter will be used to render the content block.
-
#title ⇒ String
readonly
A title for the content block.
Instance Method Summary collapse
-
#render ⇒ string
Calls the appropriate presenter class to return a HTML representation of a content block.
Instance Attribute Details
#content_id ⇒ String (readonly)
The content UUID for a block
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/content_block_tools/content_block.rb', line 36 class ContentBlock < Data # A lookup of presenters for particular content block types CONTENT_PRESENTERS = { "content_block_email_address" => ContentBlockTools::Presenters::EmailAddressPresenter, }.freeze # Calls the appropriate presenter class to return a HTML representation of a content # block. Defaults to {Presenters::BasePresenter} # # @return [string] A HTML representation of the content block def render CONTENT_PRESENTERS .fetch(document_type, Presenters::BasePresenter) .new(self).render end def details to_h[:details].symbolize_keys end end |
#details ⇒ Hash (readonly)
A hash that contains the details of the content block
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/content_block_tools/content_block.rb', line 36 class ContentBlock < Data # A lookup of presenters for particular content block types CONTENT_PRESENTERS = { "content_block_email_address" => ContentBlockTools::Presenters::EmailAddressPresenter, }.freeze # Calls the appropriate presenter class to return a HTML representation of a content # block. Defaults to {Presenters::BasePresenter} # # @return [string] A HTML representation of the content block def render CONTENT_PRESENTERS .fetch(document_type, Presenters::BasePresenter) .new(self).render end def details to_h[:details].symbolize_keys end end |
#document_type ⇒ String (readonly)
The document type of the content block - this will be used to work out which Presenter will be used to render the content block. All supported document_types are documented in ContentBlockTools::ContentBlockReference::SUPPORTED_DOCUMENT_TYPES
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/content_block_tools/content_block.rb', line 36 class ContentBlock < Data # A lookup of presenters for particular content block types CONTENT_PRESENTERS = { "content_block_email_address" => ContentBlockTools::Presenters::EmailAddressPresenter, }.freeze # Calls the appropriate presenter class to return a HTML representation of a content # block. Defaults to {Presenters::BasePresenter} # # @return [string] A HTML representation of the content block def render CONTENT_PRESENTERS .fetch(document_type, Presenters::BasePresenter) .new(self).render end def details to_h[:details].symbolize_keys end end |
#title ⇒ String (readonly)
A title for the content block
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/content_block_tools/content_block.rb', line 36 class ContentBlock < Data # A lookup of presenters for particular content block types CONTENT_PRESENTERS = { "content_block_email_address" => ContentBlockTools::Presenters::EmailAddressPresenter, }.freeze # Calls the appropriate presenter class to return a HTML representation of a content # block. Defaults to {Presenters::BasePresenter} # # @return [string] A HTML representation of the content block def render CONTENT_PRESENTERS .fetch(document_type, Presenters::BasePresenter) .new(self).render end def details to_h[:details].symbolize_keys end end |
Instance Method Details
#render ⇒ string
Calls the appropriate presenter class to return a HTML representation of a content block. Defaults to Presenters::BasePresenter
46 47 48 49 50 |
# File 'lib/content_block_tools/content_block.rb', line 46 def render CONTENT_PRESENTERS .fetch(document_type, Presenters::BasePresenter) .new(self).render end |