Hello all, and specially John. It's so good to see you back in
business :-)

I'm trying to use the "set" expression to change the value of a field,
deep in a hash:

In the process:definition:
   set 'f:authinfo.last_proceeded.owner_groups' => '$v:owner_groups'

However, the expression above doesn't seem to work:

---8<---
    {"authinfo"=>
      {"initiator"=>{"user"=>"alice", "ipaddr"=>"127.0.0.1"},
       "last_updated"=>{"user"=>"none", "ipaddr"=>nil, "tstamp"=>nil},
       "last_proceeded"=>
        {"action"=>"none",
         "user"=>"none",
         "ipaddr"=>nil,
         "tstamp"=>nil,
         "owner_groups"=>[],
         "user_groups"=>[]}},
     "__tags__"=>[],
     "authinfo.last_proceeded.owner_groups"=> ["trafico",
"contabilidad", "administracion"],
-->8--

Notice that the last line contains a literal, unresolved lookup path.

Going a little bit further, I double-checked that the unit test for
lookups accepted this kind of "deep set"


"test/unit/ut_11_lookup.rb"
---8<---
   def test_set

     h = { 'customer' => { 'name' => 'alpha' } }
     Ruote.set(h, 'customer.name', 'bravo')

     assert_equal({"customer"=>{"name"=>"bravo"}}, h)
   end
  -->8--

So I wrote a new unit test, just to make sure:

---8<---
   def test_deep_set

     h = {'foo'=>{'bar'=>{'baz'=>{'fruit'=>'pineapple'}}}}
     Ruote.set(h, 'foo.bar.baz.fruit', 'orange')

     assert_equal({"foo"=>{"bar"=>{"baz"=> "orange" }}}, h)
   end

  -->8--

And executed the specific suite:

coruscant:ruote nando$ ruby test/unit/ut_11_lookup.rb
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
Fri Apr 08 19:39:08 +0200 2011
Loaded suite test/unit/ut_11_lookup
Started
...F.......
Finished in 0.011963 seconds.

  1) Failure:
test_deep_set(LookupTest) [test/unit/ut_11_lookup.rb:54]:
<{"foo"=>{"bar"=>{"baz"=>"orange"}}}> expected but was
<{"foo"=>{"bar"=>{"baz"=>{"fruit"=>"pineapple"}}},
 "foo.bar.baz.fruit"=>"orange"}>.

11 tests, 16 assertions, 1 failures, 0 errors

  -->8--

So, is this a bug or am I doing things wrong?

As always, many thanks for the help. Have a good weekend

//nando

-- 
you received this message because you are subscribed to the "ruote users" group.
to post : send email to [email protected]
to unsubscribe : send email to [email protected]
more options : http://groups.google.com/group/openwferu-users?hl=en

Reply via email to