Module: RichText::Attributes Private
- Defined in:
- lib/rich-text/attributes.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
- .compose(a, b, keep_nil) ⇒ Object private
- .diff(a, b) ⇒ Object private
- .transform(a, b, priority) ⇒ Object private
Class Method Details
.compose(a, b, keep_nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 8 9 10 11 |
# File 'lib/rich-text/attributes.rb', line 5 def compose(a, b, keep_nil) return b if a.nil? return a if b.nil? result = b.merge(a) { |k,vb,va| vb } result.delete_if { |k,v| v.nil? } unless keep_nil result end |
.diff(a, b) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 16 17 18 19 |
# File 'lib/rich-text/attributes.rb', line 13 def diff(a, b) return b if a.nil? return a if b.nil? (a.keys | b.keys).each_with_object({}) do |key, memo| memo[key] = b[key] if a[key] != b[key] end end |
.transform(a, b, priority) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 24 25 26 |
# File 'lib/rich-text/attributes.rb', line 21 def transform(a, b, priority) return b if a.nil? || a.empty? || b.nil? || b.empty? || !priority (b.keys - a.keys).each_with_object({}) do |key, memo| memo[key] = b[key] end end |