class NdTranscriber::Copier
Attributes
dest[RW]
origin[RW]
Public Class Methods
new(origin, dest)
click to toggle source
# File lib/nd_transcriber/copier.rb, line 5 def initialize origin, dest self.origin, self.dest = origin, dest end
Public Instance Methods
copy(field, to: field) { |value| ... }
click to toggle source
# File lib/nd_transcriber/copier.rb, line 22 def copy field, to: field value = (field && origin.respond_to?(field) ? origin.send(field) : nil ) value = yield(value) if block_given? if to.is_a?(Array) to.each do |f| dest.send("#{f}=", value) end else dest.send("#{to}=", value) end end
copy_fields(*fields)
click to toggle source
# File lib/nd_transcriber/copier.rb, line 9 def copy_fields *fields fields.each do |field| if field.is_a?(Hash) field.each_pair do |from, to| copy from, to: to end else copy field end end dest end
method_missing(method, *args, &block)
click to toggle source
# File lib/nd_transcriber/copier.rb, line 34 def method_missing method, *args, &block dest.send(method, *args, &block) end