Class: DraftjsExporter::Entities::Link
- Inherits:
-
Object
- Object
- DraftjsExporter::Entities::Link
- Defined in:
- lib/draftjs_exporter/entities/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 }) ⇒ Link
constructor
A new instance of Link.
Constructor Details
#initialize(configuration = { className: nil }) ⇒ Link
Returns a new instance of Link.
7 8 9 |
# File 'lib/draftjs_exporter/entities/link.rb', line 7 def initialize(configuration = { className: nil }) @configuration = configuration end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
5 6 7 |
# File 'lib/draftjs_exporter/entities/link.rb', line 5 def configuration @configuration end |
Instance Method Details
#call(parent_element, data) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/draftjs_exporter/entities/link.rb', line 11 def call(parent_element, data) args = { href: data.fetch(:data, {}).fetch(:url) } args[:class] = configuration.fetch(:className) if configuration[:className] element = parent_element.document.create_element('a', args) parent_element.add_child(element) element end |