lib/sub_diff/builder.rb in sub_diff-1.0.6 vs lib/sub_diff/builder.rb in sub_diff-1.0.7
- old
+ new
@@ -1,10 +1,12 @@
module SubDiff
class Builder
- def initialize(string, type)
+ attr_reader :string, :diff_method
+
+ def initialize(string, diff_method)
@string = string
- @type = type
+ @diff_method = diff_method
end
def diff(*args, &block)
build_diff_collection do
adapter.diff(*args, &block)
@@ -19,32 +21,22 @@
end
alias_method :<<, :push
private
- attr_reader :string, :type
-
def build_diff_collection(&block)
collection.reset(&block).dup
end
def collection
@collection ||= Collection.new(string)
end
def adapter
- adapter_class.new(differ)
+ @adapter ||= Adapter.new(differ)
end
- def adapter_class
- Module.nesting.last.const_get(adapter_name)
- end
-
- def adapter_name
- type.to_s.capitalize
- end
-
def differ
- Differ.new(self, type)
+ @differ ||= Differ.new(self)
end
end
end