Class: TestLink::Adapters::NodeAdapter

Inherits:
Base
  • Object
show all
Defined in:
lib/test_link/adapters/node_adapter.rb

Instance Attribute Summary

Attributes inherited from Base

#response

Instance Method Summary collapse

Methods inherited from Base

#adapt

Instance Method Details

#adapt_row(row) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/test_link/adapters/node_adapter.rb', line 34

def adapt_row row
  node = TestLink::Objects::Node.new
  node.id = row['id'].to_i
  node.parent_id = row['parent_id'].to_i
  node.type_id = row['node_type_id'].to_i
  node.table = row['node_table'] if row.has_key? 'node_table'
  node.order = row['node_order'].to_i
  node.name = row['name']
  node.details = row['details'] if row.has_key? 'details'
  node
end

#response=(response) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/test_link/adapters/node_adapter.rb', line 23

def response= response
  if response.instance_of? Hash
    if response.has_key?('node_type_id')
      response = [ response ]
    elsif response.count > 1 && response.keys.reject { |key| key =~ /\A\d+?\z/ }.count == 0
      response = response.values
    end
  end
  super response
end