Class: BlueberryCMS::PageBlocks::Shared

Inherits:
BlueberryCMS::PageBlock show all
Defined in:
app/models/blueberry_cms/page_blocks/shared.rb

Constant Summary

Constants inherited from BlueberryCMS::PageBlock

BlueberryCMS::PageBlock::MARGINS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BlueberryCMS::PageBlock

#to_partial_path, types, #used_for_sharing?

Class Method Details

.avaible_shared_blocks_for_selectObject



6
7
8
9
10
11
12
# File 'app/models/blueberry_cms/page_blocks/shared.rb', line 6

def self.avaible_shared_blocks_for_select
  blocks = BlueberryCMS::Page.all.map(&:blocks).flatten.select(&:shared)

  blocks.map do |block|
    [[block.page.name, block.decorate.label].join(' | '), block.id]
  end
end

Instance Method Details

#blockObject



19
20
21
22
# File 'app/models/blueberry_cms/page_blocks/shared.rb', line 19

def block
  return nil unless page_by_block
  page_by_block&.blocks&.find(block_id)
end

#page_by_blockObject



14
15
16
17
# File 'app/models/blueberry_cms/page_blocks/shared.rb', line 14

def page_by_block
  return nil unless block_id?
  BlueberryCMS::Page.find_by('blocks._id' => block_id)
end