lib/mystique.rb in mystique-0.5.0 vs lib/mystique.rb in mystique-0.5.1

- old
+ new

@@ -41,22 +41,25 @@ private def method_missing(method, *args, &block) return target.send(method, *args, &block) if method.to_s.start_with?("to_") - value = target.send(method, *args, &block) + format( target.send(method, *args, &block) ) + end + + def format(value) result = if __formats__.keys.include?(value) __formats__[value] elsif __regex_formats__.any? { |regex, _| value =~ regex} __regex_formats__.select { |regex, _| value =~ regex}.first.last elsif __class_formats__.any? { |klass, _| value.is_a?(klass)} __class_formats__.select { |klass, _| value.is_a?(klass)}.first.last else value end - Mystique.present(Callable(result).call(value, context)) + Mystique.present(Callable(result).call(value, context)) end - + def self.context(ctx=Undefined) @__context__ = ctx unless ctx == Undefined @__context__ end