Class: Spina::Parts::ContentBlocks

Inherits:
Base
  • Object
show all
Includes:
AttrJson::NestedAttributes
Defined in:
app/models/spina/parts/content_blocks.rb

Direct Known Subclasses

NestedContentBlocks

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



11
12
13
# File 'app/models/spina/parts/content_blocks.rb', line 11

def options
  @options
end

Instance Method Details

#available_templates(theme) ⇒ Object

Returns available content block templates from the theme, optionally filtered by the :content_block_templates option.



15
16
17
18
19
20
21
22
# File 'app/models/spina/parts/content_blocks.rb', line 15

def available_templates(theme)
  templates = theme.content_block_templates || []
  allowed = options&.dig(:content_block_templates)
  return templates if allowed.blank?

  allowed_names = Array(allowed).map(&:to_s)
  templates.select { |t| allowed_names.include?(t[:name].to_s) }
end