Class: EmbeddableContent::RecordNodeProcessor
Constant Summary
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
#doc_processor, #error, #node, #node_index
Attributes inherited from EmbedderBase
#config, #options
Instance Method Summary
collapse
#initialize, #node_added_classes, #process!
default_s3_bucket, #ed_node, #initialize, #locale, #s3_bucket, #target, #to_s, #tree, #tree_node
Instance Method Details
#attached_file ⇒ Object
40
41
42
|
# File 'app/services/embeddable_content/record_node_processor.rb', line 40
def attached_file
record.file
end
|
#cms_url ⇒ Object
26
27
28
|
# File 'app/services/embeddable_content/record_node_processor.rb', line 26
def cms_url
src_url
end
|
#node_selector_class ⇒ Object
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
|
#record ⇒ Object
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_id ⇒ Object
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_model ⇒ Object
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_url ⇒ Object
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
|