Class: Katalyst::Content::DuplicatesRichText::DupRichText
- Inherits:
-
Object
- Object
- Katalyst::Content::DuplicatesRichText::DupRichText
- Defined in:
- app/models/concerns/katalyst/content/duplicates_rich_text.rb
Overview
Duplicates a has_rich_text attribute from source to target. Public API: can be used directly for models that want to duplicate a specific rich text attribute without including the concern, e.g. DuplicatesRichText::DupRichText.new(:subtitle).apply(source, self)
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #apply(source, target) ⇒ Object
-
#initialize(name) ⇒ DupRichText
constructor
A new instance of DupRichText.
Constructor Details
#initialize(name) ⇒ DupRichText
Returns a new instance of DupRichText.
26 27 28 |
# File 'app/models/concerns/katalyst/content/duplicates_rich_text.rb', line 26 def initialize(name) @name = name.to_s end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
24 25 26 |
# File 'app/models/concerns/katalyst/content/duplicates_rich_text.rb', line 24 def name @name end |
Instance Method Details
#apply(source, target) ⇒ Object
30 31 32 33 34 35 36 |
# File 'app/models/concerns/katalyst/content/duplicates_rich_text.rb', line 30 def apply(source, target) rich_text = source.public_send("rich_text_#{name}") # copy via body assignment so that custom attribute writers # (e.g. Table#content=) are not re-run on the duplicate target.public_send(name).body = rich_text.body if rich_text end |