~akretion-team/oerpscenario/core

« back to all changes in this revision

Viewing changes to lib/cucumber/openerp/dsl.rb

  • Committer: nicolas.bessi at camptocamp
  • Date: 2012-06-12 16:12:10 UTC
  • Revision ID: nicolas.bessi@camptocamp.com-20120612161210-42gn0hff7rgrrb26
[IMP] performance

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
  end
27
27
  command_map = {'create' => 'new', 'need' => 'find_or_initialize_by_', 'shoud_have' => "find_#{qty}by_", 'find' => "find_#{qty}by_", 'find or create' => 'find_or_initialize_by_'}
28
28
  comm_ext, arguments = prepare_args(args)
 
29
  arguments.push({:fields=>['id']})
29
30
  if command_map[action] == 'create'
30
31
    if oclass.send(('find_by_'+comm_ext).to_sym, *arguments)
31
32
      raise "Error object allerady exist if this is not the wished behavior please use need keyword"
44
45
  oid = nil
45
46
  if value.start_with? 'by '
46
47
    comm_ext, arguments = prepare_args(value.gsub('by ', ''))
47
 
    arguments.push({'fields'=>['id']})
 
48
    arguments.push({:fields=>['id']})
48
49
    oid = oclass.send(('find_by_'+comm_ext).to_sym, *arguments)
49
50
  else
50
51
    eval "oid = oclass.#{value}"