Module: Itext::Attachments
- Included in:
- Itext
- Defined in:
- lib/itext/attachments.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #add_attachments(attachments) ⇒ Object (also: #add_attachment)
- #initialize(*args, &block) ⇒ Object
- #remove_attachments(attachments) ⇒ Object (also: #remove_attachment)
Class Method Details
.included(base) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/itext/attachments.rb', line 9 def self.included(base) base.extend(ClassMethods) attr_reader :attachments # base.class_eval do # original_method = instance_method(:initialize) # define_method(:initialize) do |*args, &block| # original_method.bind(self).call(*args, &block) # @hooks.push ->{ process_attachments } # end # end end |
Instance Method Details
#add_attachments(attachments) ⇒ Object Also known as: add_attachment
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/itext/attachments.rb', line 22 def () @attachments ||= [] = [] unless .is_a?(Array) .each do || if File.exists?() @attachments << end end @attachments end |
#initialize(*args, &block) ⇒ Object
4 5 6 7 |
# File 'lib/itext/attachments.rb', line 4 def initialize(*args, &block) @hooks ||= [] @hooks.push ->{ } end |
#remove_attachments(attachments) ⇒ Object Also known as: remove_attachment
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/itext/attachments.rb', line 35 def () @attachments ||= [] = [] unless .is_a?(Array) .each do || if File.exists?() @attachments.delete() end end @attachments end |