Class: EmbeddableContent::RecordNodeProcessor

Inherits:
NodeProcessor show all
Defined in:
app/services/embeddable_content/record_node_processor.rb

Constant Summary

Constants inherited from NodeProcessor

NodeProcessor::ADDED_CLASSES_BLANK_BY_DEFAULT, NodeProcessor::ALL_TARGETS_PROCESSED_BY_DEFAULT, NodeProcessor::DEFAULT_TEMPLATE_MANAGER_CLASS, NodeProcessor::NODE_CAN_BE_REMOVED_BY_DEFAULT, NodeProcessor::RECORD_BLANK_BY_DEFAULT, NodeProcessor::SELECTOR_CLASS_BLANK_BY_DEFAULT

Instance Attribute Summary

Attributes inherited from NodeProcessor

#doc_processor, #error, #node, #node_index

Attributes inherited from EmbedderBase

#config, #options

Instance Method Summary collapse

Methods inherited from NodeProcessor

#initialize, #node_added_classes, #process!

Methods inherited from EmbedderBase

default_s3_bucket, #ed_node, #initialize, #locale, #s3_bucket, #target, #to_s, #tree, #tree_node

Constructor Details

This class inherits a constructor from EmbeddableContent::NodeProcessor

Instance Method Details

#attached_fileObject



40
41
42
# File 'app/services/embeddable_content/record_node_processor.rb', line 40

def attached_file
  record.file
end

#cms_urlObject



26
27
28
# File 'app/services/embeddable_content/record_node_processor.rb', line 26

def cms_url
  src_url
end

#node_selector_classObject



44
45
46
# File 'app/services/embeddable_content/record_node_processor.rb', line 44

def node_selector_class
  "embedded-content-#{record_model.model_name.param_key.dasherize}"
end

#recordObject



18
19
20
# File 'app/services/embeddable_content/record_node_processor.rb', line 18

def record
  @record ||= target_scope.find record_id
end

#record_css_id_for(type) ⇒ Object



14
15
16
# File 'app/services/embeddable_content/record_node_processor.rb', line 14

def record_css_id_for(type)
  "#{type}-#{record_model}-#{record_id}"
end

#record_idObject



5
6
7
# File 'app/services/embeddable_content/record_node_processor.rb', line 5

def record_id
  @record_id ||= tag_match_data[:id] if tag_references_record?
end

#record_modelObject



9
10
11
12
# File 'app/services/embeddable_content/record_node_processor.rb', line 9

def record_model
  @record_model ||= tag_match_data[:model].classify.constantize if
    tag_references_record?
end

#s3_ttl_urlObject



30
31
32
33
34
35
36
37
38
# File 'app/services/embeddable_content/record_node_processor.rb', line 30

def s3_ttl_url
  if Rails.env.test?
    Pathname
      .new(ActiveStorage::Blob.service.send(:path_for, blob.key))
      .relative_path_from Rails.root
  else
    blob.url(content_type: content_type)
  end
end

#s3_url(with_extension: false) ⇒ Object



22
23
24
# File 'app/services/embeddable_content/record_node_processor.rb', line 22

def s3_url(with_extension: false)
  with_extension ? s3_url_with_extension : bare_s3_url
end