Module: Eve::API::Response::Rowsets

Included in:
Eve::API::Response
Defined in:
lib/eve/api/response/rowsets.rb

Instance Method Summary collapse

Instance Method Details

#add_rowset(rowset) ⇒ Object



9
10
11
12
# File 'lib/eve/api/response/rowsets.rb', line 9

def add_rowset(rowset)
  rowsets << rowset
  rowset.delegate_from(self)
end

#copy_attributes(columns, row_element, into = self) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/eve/api/response/rowsets.rb', line 16

def copy_attributes(columns, row_element, into = self)
  attributes = row_element.attributes.to_hash.rename((@options[:column_mapping] || {}))

  #missing_attributes = columns - attributes.keys
  #extra_attributes = attributes.keys - columns
  #raise Eve::Errors::InvalidRowset,
  #      "Missing attributes from row: #{missing_attributes.inspect}" if !missing_attributes.empty?
  #raise Eve::Errors::InvalidRowset,
  #      "Extra attributes in row: #{extra_attributes.inspect}" if !extra_attributes.empty?
  if !into.respond_to?(:wrap_object)
    klass = into.class
    klass.send(:include, WrapObject)
  end
  columns.each do |column|
    into.send(:wrap_object, column, value_for(attributes[column]))
  end
end

#rowset_namesObject



5
6
7
# File 'lib/eve/api/response/rowsets.rb', line 5

def rowset_names
  rowsets.collect { |c| c.name }
end

#rowsetsObject



14
# File 'lib/eve/api/response/rowsets.rb', line 14

def rowsets; @rowsets ||= []; end

#value_for(candidate) ⇒ Object



34
35
36
37
38
# File 'lib/eve/api/response/rowsets.rb', line 34

def value_for(candidate)
  candidate.kind_of?(String) ? YAML::load(candidate) : candidate
rescue (defined?(Psych::SyntaxError) ? Psych::SyntaxError : StandardError)
  candidate
end