Thomas Mueller wrote:
> Hi,
>
> I am using JRuby to access data in some business application (Siebel,
> if anybody is interested).
> In Siebel I need to activate fields if I want to access them later:
>
> bc.activate_field(name)
> bc.query(search_specs)
> do stuff
>
> I've written methods that do the query and then yield each record to a
> given block, so I can write something like:
>
> bc.activate_field("field1")
> bc.activate_field("field2")
> bc.find_all(search_specs) do |record|
>   record["field1"] = "some value"
>   puts record["field2"]
> end
>
> I would like to do the activate_field() calls automatically, based on
> which fields are being accessed inside the block.
> Is it possible to look into the block and find out which fields are
> being accessed? In the above example that would include the fields
> "field1" and "field2".
> Basically, can I access the code inside the block and inspect it?
>
> Thomas

bc.find_all(search_specs,'field1','field2') { |record,fields|
  record[field[0]] = "some value"
  puts record[field[1]]
}