Class: Bushido::Data

Inherits:
Object
  • Object
show all
Extended by:
Hooks
Defined in:
lib/bushido/data.rb

Overview

:nodoc:

Class Method Summary collapse

Methods included from Hooks

fire, listen

Class Method Details

.attach(*models) ⇒ Object



7
8
9
10
# File 'lib/bushido/data.rb', line 7

def attach(*models)
  # Total no-op, we just need to load the classes in order to
  # register the hooks, and this does that.
end

.publish(model, model_data) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bushido/data.rb', line 13

def publish(model, model_data)
  # POST to /apps/:id/bus
  data = {}
  data[:key] = Bushido::Platform.key

  data["data"]  = model_data
  data["data"]["ido_model"] = model
  #puts "Publishing Ido model"
  #puts data.to_json
  #puts Bushido::Platform.publish_url

  # TODO: Catch non-200 response code
  response = JSON.parse(RestClient.post(Bushido::Platform.publish_url, data.to_json, :content_type => :json, :accept => :json))
  if response['ido_id'].nil? or response['ido_version'].nil?
    return false
  end

  return response
end