Module: Fog::VcloudDirector::Query

Instance Method Summary collapse

Instance Method Details

#find_by_query(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/query.rb', line 6

def find_by_query(options={})
  type = options.fetch(:type) { self.query_type }

  results = get_all_results(type, options)
  data = results.map do |query_record|
    model_data = {}
    model_data[:id] = query_record[:href].split('/').last
    model_data[:name] = query_record.fetch(:name) if query_record.key?(:name)
    if self.methods.include?(:populate_model_from_query_record)
      model_data.merge(self.populate_model_from_query_record(query_record))
    else
      model_data
    end
  end
  load(data)
end