Class: Decidim::ContentBlockManifest

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, AttributeObject::Model
Defined in:
lib/decidim/content_block_manifest.rb

Overview

This class acts as a manifest for content blocks.

A content block is a view section in a given page. Those sections can be registered by Decidim modules, and are configurable and sortable. They are a useful way to customize a given page, without having to rely on overwriting the views files. Also, this system is more powerful than basic view hooks (see the ‘ViewHooks` class for reference), as view hooks do not have a way to explicitly control the order of the hooked views.

Content blocks are intended to be used in the home page, for example.

A content block has a set of settings and an associated ‘cell` that will handle the layout logic. They can also have attached images that can be used as background images, for example. You must explicitly specify the number of images the block will have (this means the number of attached images cannot be configurable). Each content block is identified by a name, which has to be unique per scope.

Constant Summary

Constants included from AttributeObject::TypeMap

AttributeObject::TypeMap::Boolean, AttributeObject::TypeMap::Decimal

Instance Method Summary collapse

Methods included from AttributeObject::Model

#[], #[]=, #attributes, #attributes_with_values, #initialize, #to_h

Instance Method Details

#default!Object

Public: Registers whether this content block should be shown by default when creating an organization. Use ‘#default` to retrieve it.



40
41
42
# File 'lib/decidim/content_block_manifest.rb', line 40

def default!
  self.default = true
end

#has_settings?Boolean

Returns:



44
45
46
# File 'lib/decidim/content_block_manifest.rb', line 44

def has_settings?
  settings.attributes.any?
end

#settings {|@settings| ... } ⇒ Object

Yields:



48
49
50
51
52
# File 'lib/decidim/content_block_manifest.rb', line 48

def settings(&block)
  @settings ||= SettingsManifest.new
  yield(@settings) if block
  @settings
end