Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Coerce improvements #96

merged 2 commits into from May 10, 2013
Commits on May 9, 2013
  1. Coercion improvements, specs passing

    wapcaplet committed May 9, 2013
    In `Hashie::Mash`, implement `#[]` and `#[]=` as `#custom_reader` and
    `#custom_writer`, respectively, so they can be called explicitly
    (aliases provided for backward compatibility). The `#deep_update` method
    now uses the custom reader/writer methods, instead of the regular
    reader/writer methods (which bypass coercion).
    In `Coercion`, override `#custom_writer` to use the coercing setter
    method. Additionally, force `.to_sym` on keys passed to `#key_coercion`,
    to allow the string keys used by `Hashie::Mash` to work.
    These together allow coercion to work with `Hashie::Mash` instances,
    not only with direct `mash[:key]` symbolic indexing, but with `mash.key`
    attribute style, `mash['key']` string indexing, and `Mash.new(:key =>
    ...)` instance initialization.
    All spec tests are passing now.