lib/sub_diff/diff.rb in sub_diff-0.0.0 vs lib/sub_diff/diff.rb in sub_diff-1.0.0

- old
+ new

@@ -1,22 +1,22 @@ +require 'delegate' + module SubDiff - class Diff - attr_reader :value, :value_was - alias_method :to_s, :value + class Diff < SimpleDelegator + attr_reader :value_was + alias_method :value, :__getobj__ + def initialize(value, value_was = nil) - @value, @value_was = value, value_was || value + @value_was = value_was || value + super(value) end def changed? - @changed ||= value != value_was + value != value_was end - def method_missing(*args, &block) - to_s.send(*args, &block) + def empty? + value.empty? && !changed? end - - def respond_to_missing?(method, include_private) - to_s.respond_to?(method, include_private) - end end -end \ No newline at end of file +end