Thank you very much for your answer, John.
There was an error in my code, it should be this way:
########### START CODE ##############
def workitems_by_type_and_by_space(type, space)
workitem_list = []
store_names.each do |store_name|
workitems = workitems(store_name)
workitems.each_with_index do |workitem, i|
type_mach = false
space_mach = false
workitem.fields_hash.each do |k, v|
if (k == "type" and v == type) ## LINE CHANGED
type_mach = true
end
if (k == "space" and v == space) ## LINE CHANGED
space_mach = true
end
end
if type_mach and space_mach
workitem_list << workitem
end
end
end
workitem_list
end
###### END CODE ##############
But you get the same results... with eight line function! It's obvious that
I am a newbie ruby programmer.
Also, I think the new worklist.workitems() feature will very usefull. You
are great! You opened and closed a ticked in the tracker system at the same
day.
Best regards,
Diego.
2008/5/15 John Mettraux <[EMAIL PROTECTED]>:
>
> On Thu, May 15, 2008 at 2:44 AM, Diego Moreno <[EMAIL PROTECTED]>
> wrote:
> >
> > After thinking about all possible options, I try this. In worklist
> > model I add this function:
> >
> > ########### START CODE ##############
> > def workitems_by_type_and_by_space(type, space)
>
> Hi Diego,
>
> I don't see the parameters type and space of your function being used.
> Is that what you mean :
>
> ---8<---
> def workitems_by_type_and_by_space (type, space)
>
> workitem_list = []
>
> store_names.each do |store_name|
> workitems(store_name).each do |workitem|
> h = workitem.fields_hash
> workitem_list << workitem if (h['type'] == type and h['space'] ==
> space)
> end
> end
>
> workitem_list
> end
> --->8---
>
> ?
>
> I will probably update the workitems() method of worklist so that it
> returns all the workitems the user has access to if you pass no store
> name, it will allow for :
>
> ---8<---
> def workitems_by_type_and_by_space (type, space)
>
> workitems.inject([]) do |result, workitem|
> h = workitem.fields_hash
> result << workitem if (h['type'] == type and h['space'] == space)
> result
> end
> end
> --->8---
>
>
> http://rubyforge.org/tracker/index.php?func=detail&aid=20146&group_id=2609&atid=10195
>
> (inject() is a great method, see
> http://www.ruby-doc.org/core/classes/Enumerable.html#M003160)
>
>
> Thanks for the feedback, best regards,
>
> --
> John Mettraux - http://jmettraux.wordpress.com
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"OpenWFEru users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/openwferu-users?hl=en
-~----------~----~----~----~------~----~------~--~---