Class: Workarea::Content::BlockDraft

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Attributes::Dynamic, ApplicationDocument
Defined in:
app/models/workarea/content/block_draft.rb

Instance Method Summary collapse

Methods included from ApplicationDocument

#releasable?

Methods included from Sidekiq::Callbacks

add_worker, assert_valid_config!, async, caching_classes?, disable, enable, inline, #run_callbacks, workers, workers_list

Instance Method Details

#block_typeObject



20
21
22
23
# File 'app/models/workarea/content/block_draft.rb', line 20

def block_type
  return unless type_id.present?
  Workarea.config.content_block_types.detect { |bt| bt.id == type_id.to_sym }
end

#contentObject



16
17
18
# File 'app/models/workarea/content/block_draft.rb', line 16

def content
  Content.find(content_id)
end

#to_blockObject



31
32
33
# File 'app/models/workarea/content/block_draft.rb', line 31

def to_block
  content.blocks.build(attributes.except('content_id'))
end

#typecast_data!Object



25
26
27
28
29
# File 'app/models/workarea/content/block_draft.rb', line 25

def typecast_data!
  return unless type_id.present? && data.present?
  self.data = block_type.try(:typecast!, data)
  self
end