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, "content_block_postal_address" => ContentBlockTools::Presenters::PostalAddressPresenter, "content_block_pension" => ContentBlockTools::Presenters::PensionPresenter, }.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.
-
#embed_code ⇒ Object
readonly
The embed_code used for a block containing optional field name @example content_block_reference.embed_code #=> “{embed:content_block_email_address:2b92cade-549c-4449-9796-e7a3957f3a86}” content_block_reference.embed_code #=> “{embed:content_block_postal_address:2b92cade-549c-4449-9796-e7a3957f3a86/field_name}” @return [String].
-
#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
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/content_block_tools/content_block.rb', line 43 class ContentBlock < Data # A lookup of presenters for particular content block types CONTENT_PRESENTERS = { "content_block_email_address" => ContentBlockTools::Presenters::EmailAddressPresenter, "content_block_postal_address" => ContentBlockTools::Presenters::PostalAddressPresenter, "content_block_pension" => ContentBlockTools::Presenters::PensionPresenter, }.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
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/content_block_tools/content_block.rb', line 43 class ContentBlock < Data # A lookup of presenters for particular content block types CONTENT_PRESENTERS = { "content_block_email_address" => ContentBlockTools::Presenters::EmailAddressPresenter, "content_block_postal_address" => ContentBlockTools::Presenters::PostalAddressPresenter, "content_block_pension" => ContentBlockTools::Presenters::PensionPresenter, }.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
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/content_block_tools/content_block.rb', line 43 class ContentBlock < Data # A lookup of presenters for particular content block types CONTENT_PRESENTERS = { "content_block_email_address" => ContentBlockTools::Presenters::EmailAddressPresenter, "content_block_postal_address" => ContentBlockTools::Presenters::PostalAddressPresenter, "content_block_pension" => ContentBlockTools::Presenters::PensionPresenter, }.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 |
#embed_code ⇒ Object (readonly)
The embed_code used for a block containing optional field name
@example
content_block_reference. #=> "{{embed:content_block_email_address:2b92cade-549c-4449-9796-e7a3957f3a86}}"
content_block_reference. #=> "{{embed:content_block_postal_address:2b92cade-549c-4449-9796-e7a3957f3a86/field_name}}"
@return [String]
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/content_block_tools/content_block.rb', line 43 class ContentBlock < Data # A lookup of presenters for particular content block types CONTENT_PRESENTERS = { "content_block_email_address" => ContentBlockTools::Presenters::EmailAddressPresenter, "content_block_postal_address" => ContentBlockTools::Presenters::PostalAddressPresenter, "content_block_pension" => ContentBlockTools::Presenters::PensionPresenter, }.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
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/content_block_tools/content_block.rb', line 43 class ContentBlock < Data # A lookup of presenters for particular content block types CONTENT_PRESENTERS = { "content_block_email_address" => ContentBlockTools::Presenters::EmailAddressPresenter, "content_block_postal_address" => ContentBlockTools::Presenters::PostalAddressPresenter, "content_block_pension" => ContentBlockTools::Presenters::PensionPresenter, }.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
55 56 57 58 59 |
# File 'lib/content_block_tools/content_block.rb', line 55 def render CONTENT_PRESENTERS .fetch(document_type, Presenters::BasePresenter) .new(self).render end |