Skip to content

Commit

Permalink
Merge pull request #130 from pjsk-stripe/remove-monkey-patching
Browse files Browse the repository at this point in the history
Remove monkey patching on Module
  • Loading branch information
satoryu authored Mar 30, 2023
2 parents 471eb15 + 5c0176b commit 2f9590f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 177 deletions.
1 change: 0 additions & 1 deletion lib/docx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ module Docx #:nodoc:
autoload :Document, 'docx/document'
end

require 'docx/core_ext/module'
172 changes: 0 additions & 172 deletions lib/docx/core_ext/module.rb

This file was deleted.

11 changes: 9 additions & 2 deletions lib/docx/elements/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ def self.included(base)
end

attr_accessor :node
delegate :at_xpath, :xpath, :to => :@node

# TODO: Should create a docx object from this
def parent(type = '*')
@node.at_xpath("./parent::#{type}")
end

def at_xpath(*args)
@node.at_xpath(*args)
end

def xpath(*args)
@node.xpath(*args)
end

# Get parent paragraph of element
def parent_paragraph
Elements::Containers::Paragraph.new(parent('w:p'))
Expand Down Expand Up @@ -102,4 +109,4 @@ def create_within(element)
end
end
end
end
end
10 changes: 8 additions & 2 deletions lib/docx/elements/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@ module Docx
module Elements
class Text
include Element
delegate :content, :content=, :to => :@node

def self.tag
't'
end

def content
@node.content
end

def content=(args)
@node.content = args
end

def initialize(node)
@node = node
end
end
end
end
end

0 comments on commit 2f9590f

Please sign in to comment.