@@ -11,9 +11,9 @@ class Transform
1111 autoload :Serializer , "moneta/transform/serializer"
1212
1313 # This helper can be used in subclasses to implement {#encode} and {#decode} by delegating to some other object. If
14- # the object delegated to responds to encode (and optionally decode) or dump (and optionally load), these will be
15- # detected automatically. Otherwise, a second argument can be supplied giving the names of the methods to use as a
16- # pair of symbols (encode then optionally decode).
14+ # the object delegated to responds to + encode+ (and optionally + decode+ ) or + dump+ (and optionally + load+ ), these
15+ # will be detected automatically. Otherwise, a second argument can be supplied giving the names of the methods to
16+ # use as a pair of symbols (+ encode+ then optionally + decode+ ).
1717 #
1818 # @example Delegate to stdlib JSON library
1919 # require 'json'
@@ -33,6 +33,17 @@ class Transform
3333 #
3434 # @param object [Module] The object to delegate to
3535 # @param methods [<Symbol,Symbol>] The methods on +object+ to delegate to
36+ #
37+ # @!macro [attach] transform_delegate_to
38+ # @!method encode(value)
39+ # Delegates to $1
40+ # @param value [Object]
41+ # @return [Object]
42+ #
43+ # @!method decode(value)
44+ # Delegates to $1
45+ # @param value [Object]
46+ # @return [Object]
3647 def self . delegate_to ( object , methods = nil )
3748 extend Forwardable
3849
@@ -56,10 +67,19 @@ def self.delegate_to(object, methods = nil)
5667
5768 # Transforms can be initialized with arbitrary keyword args. The default
5869 # initializer does nothing, just swallows the arguments it receives.
59- def initialize ( **_ )
60- end
70+ def initialize ( **_ ) end
71+
72+ # @!method encode(value)
73+ # @abstract All Subclasses should implement this method
74+ # @param value [Object] the thing to encode
75+ # @return [Object]
76+ #
77+ # @!method decode(value)
78+ # @abstract Subclasses where it is possible to decode again should implement this method
79+ # @param value [Object] the thing to decode
80+ # @return [Object]
6181
62- # Returns true if the Tranform has a {#decode} method. Some transforms
82+ # Returns true if the transform has a {#decode} method. Some transforms
6383 # (e.g. MD5) are one-way.
6484 def decodable?
6585 respond_to? :decode
0 commit comments