Hey John,
   Actually shortly after I posted, i started messing with Ruote Kit
in rails and am making adjustments with that.  But in the meantime:


================================================
def generate_process_definition

    tasks_array =%w[ task0 task1 taskC ]

      p tasks_array

    return tasks_array

  end
-------------------------------------------

.. yields via irb:

["task0", "task1", "taskC"]
=> ["task0", "task1", "taskC"]
============================================



And this works too:


==================================================
  def generate_process_definition

    input_files = %w[ test1 test2 test3 ]

    pdef = Ruote.process_definition do
      sequence do
        cleanup

      end
    end

    return pdef

  end
------------------------------------------------

yields (as expected):

["define", {}, [["sequence", {}, [["cleanup", {}, []]]]]]

=============================================================



BUT when i was calling it in a rails activerecord, 'self' appears to
be overwritten in the Dsl.  so I had to reassign any of those methods
to a variable..

this hangs after printing out the array:

=================================================
 def generate_process_definition
    puts self.input_files  # <== shows array of files
    pdef = Ruote.process_definition do
      sequence do
        concurrence do
            input_files.each do |i|
              cleanup
            end
          end
        cleanup
      end
    end
    return pdef
  end

-----------------------------------------

..yields:
>> s.generate_process_definition
dasdasd
(hang)

========================================================

BUT this worked:

==============================================
  def generate_process_definition
    ia = self.input_files
    pdef = Ruote.process_definition do
      sequence do
        concurrence do
          puts self.class
            ia.each do |i|
              cleanup
            end
          end
        cleanup
      end
    end
    return pdef
  end
-----------------------------------------------

yields..

>> s.generate_process_definition
Ruote::RubyDsl::BranchContext
=> ["define", {}, [["sequence", {}, [["concurrence", {}, [["cleanup",
{}, []]]], ["cleanup", {}, []]]]]]

=====================================================================================================


On Feb 9, 6:36 pm, John Mettraux <[email protected]> wrote:
> On Wed, Feb 10, 2010 at 3:45 AM, Dave @ UPENN <[email protected]> wrote:
>
>
>
> > argh actually that does work if i remove the |p|  sorry!
>
> > But the real problem that I'm having is actually related to using this
> > in rails.  I'm calling a method in a model called 'submission'  that
> > has many 'tasks'
>
> Hello Dave,
>
> > the process definition dsl keeps thinking that the
> > objects i'm calling in the process definition method are
> > participants.
>
> The code I write is never as smart as you write, it rather doesn't see
> any binding for "task".
>
> Please try that simple ruby program :
>
> ---8<---
> tasks =%w[ task0 task1 taskC ]
>
> def generate_definition
>   p tasks
> end
>
> generate_definition
> --->8---
>
> Observe its result.
>
> .
>
> Maybe you're better off with something that looks like :
>
> ---8<---
> require 'rubygems'
> require 'ruote'
>
> def generate_definition (name, tasks)
>
>   Ruote.process_definition :name => name do
>     tasks.each do |t|
>       participant :ref => 'x', :task => t
>     end
>   end
> end
>
> p generate_definition('a', [ 'sending season cards', 'clean garage' ])
> --->8---
>
> Best regards, thanks for using ruote,
>
> --
> John Mettraux   -  http://jmettraux.wordpress.com

-- 
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