Copy/paste bug in ArrayExtensions

1 view
Skip to first unread message

Sunshine

unread,
Nov 23, 2009, 4:29:51 PM11/23/09
to nanoc
Nanoc3::ArrayExtensions#stringify_keys incorrectly invokes
#symbolize_keys on the element even though it checks #responds_to? for
#stringify_keys.

# Returns a new array where all keys are recursively converted to
strings by calling #symbolize_keys.
def stringify_keys
inject([]) do |array, element|
array + [ element.respond_to?(:stringify_keys) ?
element.symbolize_keys : element ]
end
end

The method documentation also incorrectly mentions #symbolize_keys
rather than #stringify_keys.

-- ES

Denis Defreyne

unread,
Nov 24, 2009, 3:47:04 AM11/24/09
to na...@googlegroups.com
On 23 Nov 2009, at 22:29, Sunshine wrote:

> Nanoc3::ArrayExtensions#stringify_keys incorrectly invokes
> #symbolize_keys on the element even though it checks #responds_to? for
> #stringify_keys.
>
> [..]
>
> The method documentation also incorrectly mentions #symbolize_keys
> rather than #stringify_keys.

Hi,

Good catch--thanks for letting me know. I’m not sure what I was thinking when I wrote that piece of code, and I’m not sure either why it took so long for this bug to surface.

In any case, I’ve fixed the issue; see <http://projects.stoneship.org/hg/nanoc/rev/b351737980b4> for details. This changeset is in the 3.0.x branch, but it will be merged into trunk soon.

Regards,

Denis

--
Denis Defreyne
denis.d...@stoneship.org

Reply all
Reply to author
Forward
0 new messages