Class: DraftjsExporter::Entities::TargetBlankLink
- Inherits:
-
Object
- Object
- DraftjsExporter::Entities::TargetBlankLink
- Defined in:
- app/models/draftjs_exporter/entities/target_blank_link.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
- #call(parent_element, data) ⇒ Object
-
#initialize(configuration = { className: nil }) ⇒ TargetBlankLink
constructor
A new instance of TargetBlankLink.
Constructor Details
#initialize(configuration = { className: nil }) ⇒ TargetBlankLink
Returns a new instance of TargetBlankLink.
4 5 6 |
# File 'app/models/draftjs_exporter/entities/target_blank_link.rb', line 4 def initialize(configuration = { className: nil }) @configuration = configuration end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
2 3 4 |
# File 'app/models/draftjs_exporter/entities/target_blank_link.rb', line 2 def configuration @configuration end |
Instance Method Details
#call(parent_element, data) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'app/models/draftjs_exporter/entities/target_blank_link.rb', line 8 def call(parent_element, data) args = { href: data.fetch(:data, {}).fetch(:url) } args[:class] = configuration.fetch(:className) if configuration[:className] args[:target] = '_blank' element = parent_element.document.create_element('a', args) parent_element.add_child(element) element end |