Skip to content

Commit

Permalink
Reduce ABC complexity in wrapper state
Browse files Browse the repository at this point in the history
  • Loading branch information
theozaurus committed Jun 21, 2016
1 parent 46c1c5b commit e29a4ff
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/draftjs_exporter/wrapper_state.rb
Expand Up @@ -41,10 +41,7 @@ def parent_for(type)
new_options = nokogiri_options(*options.fetch(:wrapper))
return wrapper_element if new_options == wrapper_options

document.create_element(*new_options).tap do |new_element|
reset_wrapper.add_child(new_element)
set_wrapper(new_element, new_options)
end
create_wrapper(new_options)
end

def reset_wrapper
Expand All @@ -62,5 +59,12 @@ def nokogiri_options(element_name, element_attributes)
def block_options(type)
block_map.fetch(type).fetch(:element)
end

def create_wrapper(options)
document.create_element(*options).tap do |new_element|
reset_wrapper.add_child(new_element)
set_wrapper(new_element, options)
end
end
end
end

0 comments on commit e29a4ff

Please sign in to comment.