Given some nested data in form of a Hash:
h = {
:a => 1,
:b => {
:x => 10,
:y => 20
},
:c=>3
}
I would like to "authorize" only certain part of such data to pass in,
in a granular way.
authorize = {
:a => true,
:b => {
:x => true
}
}
I would like to get this result:
filtered = {
:a => 1,
:b => {
:x => 10
}
}
There's a way to get this in facets? Thanks!
Guido
_______________________________________________
facets-universal mailing list
facets-u...@rubyforge.org
http://rubyforge.org/mailman/listinfo/facets-universal
On Aug 5, 5:59 am, Guido De Rosa <guidoder...@gmail.com> wrote:
> Hi!
>
> Given some nested data in form of a Hash:
>
> h = {
> :a => 1,
> :b => {
> :x => 10,
> :y => 20
> },
> :c=>3
> }
>
> I would like to "authorize" only certain part of such data to pass in,
> in a granular way.
>
> authorize = {
> :a => true,
> :b => {
> :x => true
> }
> }
>
> I would like to get this result:
>
> filtered = {
> :a => 1,
> :b => {
> :x => 10
> }
> }
>
> There's a way to get this in facets? Thanks!
The first layer is easy enough:
h & [:a, :b]
You can do the second with:
h[:b] & [:x]
But I get the feeling you want something more general. As far as I can
recall at the moment, there is no such filtering method. Maybe you
would like to create one?