Class: GoodGuide::Gibbon::RuntimeClient

Inherits:
AbstractClient show all
Includes:
Util
Defined in:
lib/goodguide/gibbon.rb

Instance Method Summary collapse

Methods included from Util

#hash_to_ruby, #obj_to_js, #obj_to_ruby

Methods inherited from AbstractClient

queries, query

Instance Method Details

#missing_data!Object

Raises:



330
331
332
# File 'lib/goodguide/gibbon.rb', line 330

def missing_data!
  raise MissingData.new(@last_query_type, @last_id, @last_annotations)
end

#perform_query(id, annotations) ⇒ Object



316
317
318
319
320
321
322
323
324
325
326
327
328
# File 'lib/goodguide/gibbon.rb', line 316

def perform_query(id, annotations)
  annotations = obj_to_ruby(annotations)

  query_type = annotations.delete('_query_type')

  # stash this data in case missing_data! is called
  @last_query_type = query_type
  @last_annotations = annotations
  @last_id = id

  query = get_query(query_type)
  instance_exec(id, annotations, &query)
end

#to_jsObject



334
335
336
# File 'lib/goodguide/gibbon.rb', line 334

def to_js
  { :performQuery => proc_for(:perform_query) }
end