lib/hashformer/generate.rb in hashformer-0.2.0 vs lib/hashformer/generate.rb in hashformer-0.2.1
- old
+ new
@@ -21,10 +21,12 @@
def call(input_hash)
values = @keys.map{|k| Hashformer.get_value(input_hash, k)}
values = @block.call(*values) if @block
values
end
+
+ # TODO: Make maps chainable? Or at least add a #reduce method.
end
# Internal representation of a path to a nested key/value. Do not
# instantiate directly; call Hashformer::Generate.path (or HF::G.path)
# instead.
@@ -109,10 +111,18 @@
# Adds the given call info (used by Receiver).
def <<(info)
@calls << info
self
end
+
+ # Returns a String with the class name and a list of chained methods.
+ def to_s
+ "#{self.class.name}: #{@calls.map{|c| c[:name]}}"
+ end
+ alias inspect to_s
end
+
+ # TODO: Add a constant generator (that can be chained?)
# Generates a transformation that passes one or more values from the input
# Hash (denoted by key names or paths (see Hashformer::Generate.path) to
# the block. If the block is not given, then the values are placed in an
# array in the order in which their keys were given as parameters.