Class: BlueberryCMS::PageBlockDecorator
- Inherits:
-
BaseDecorator
- Object
- BaseDecorator
- BlueberryCMS::PageBlockDecorator
- Defined in:
- app/decorators/blueberry_cms/page_block_decorator.rb
Instance Method Summary collapse
Instance Method Details
#block_object ⇒ Object
3 4 5 |
# File 'app/decorators/blueberry_cms/page_block_decorator.rb', line 3 def block_object is_a?(BlueberryCMS::PageBlocks::Shared) ? block.decorate : self end |
#computed_classes ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/decorators/blueberry_cms/page_block_decorator.rb', line 7 def computed_classes array = [css_class] array << "block--mt-#{top_margin}" if top_margin? array << "block--mt-#{top_margin_xs}-mobile" if top_margin_xs? array << "block--mb-#{bottom_margin}" if bottom_margin? array << "block--mb-#{bottom_margin_xs}-mobile" if bottom_margin_xs? array << "block--gallery-text-#{orientation}" if respond_to?(:orientation) array << 'block--bg-fractals white' if try(:red_background) if object.is_a?(BlueberryCMS::PageBlocks::VideoGallery) array << 'block--bg-fractals white block--videogallery' end array.join(' ') end |
#label ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/decorators/blueberry_cms/page_block_decorator.rb', line 24 def label text = if object.respond_to?(:name) object.name elsif object.respond_to?(:title) object.title elsif object.respond_to?(:content) h.(object.content) elsif object.is_a?(BlueberryCMS::PageBlocks::Shared) [object.block&.page&.name, object.block&.decorate&.label].compact.join(' | ') end [object.model_name.human, h.truncate(text, length: 90)].compact.join(' - ') end |
#name ⇒ Object
38 39 40 |
# File 'app/decorators/blueberry_cms/page_block_decorator.rb', line 38 def name process_markdown(object.name) if object.name.present? end |
#title ⇒ Object
42 43 44 |
# File 'app/decorators/blueberry_cms/page_block_decorator.rb', line 42 def title process_markdown(object.title) if object.title.present? end |