Class: Smithy::ContentBlocks::Registry
- Inherits:
-
Object
- Object
- Smithy::ContentBlocks::Registry
- Defined in:
- lib/smithy/content_blocks/registry.rb
Constant Summary collapse
- @@content_blocks =
[]
Class Method Summary collapse
Class Method Details
.clear ⇒ Object
10 11 12 |
# File 'lib/smithy/content_blocks/registry.rb', line 10 def clear @@content_blocks = [] end |
.content_blocks ⇒ Object
14 15 16 |
# File 'lib/smithy/content_blocks/registry.rb', line 14 def content_blocks @@content_blocks end |
.register(content_block) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/smithy/content_blocks/registry.rb', line 18 def register(content_block) return unless ActiveRecord::Base.connection.table_exists?(Smithy::ContentBlock.table_name) return unless ActiveRecord::Base.connection.table_exists?(content_block.table_name) content_block_name = content_block.to_s.demodulize @@content_blocks << content_block_name unless @@content_blocks.include?(content_block_name) Smithy::ContentBlock.find_or_create_by(name: content_block_name) @@content_blocks end |