I use the following class definition
class Workflow
# class << self; attr_acessor :id, :name, :url end
# Please ignore the troubleshooting attemp above it didn't help, I got the ObjectNil
def self.initialize ( id, name, url )
@id = id
@name = name
@url = url
end
# @return [Object]
def self.list
ret = Array.new
wf = Hash.new
vco = Vco.new
vco.getAll.each do |link|
link['attributes'].each do |attr|
wf[ attr['name'] ] = attr[ 'value' ]
end
ret.push( self.new( wf[ 'id' ], wf[ 'name' ], wf[ 'itemHref' ] ) )
end
return ret
end
used as:
<% @workflows.each do |wf| %>
<tr>
<td><%= wf.id %></td>
<td><%= wf.name %></td>
<td><%= wf.url %></td>
</tr>
<% end %>
Thus the method Workflow.list should return an array of workflows. However, it doesn't do so as expected. When I use
ret.push( self.new( wf[ 'id' ], wf[ 'name' ], wf[ 'itemHref' ] ) )
I'm getting the "wrong number of arguments(3 for 0)" error. But when I use instead
ret.push( self.initialize( wf[ 'id' ], wf[ 'name' ], wf[ 'itemHref' ] ) )
the method list returns a list of url strings (it is the last assignment in the method, and should be that) What am I doing wrong?
initialise? Show the definition of it.