Sha256: d3dce1cf1e525702e1229dfb87477d27d7854ad92e332908271e089f8887e776

Contents?: true

Size: 890 Bytes

Versions: 3

Compression:

Stored size: 890 Bytes

Contents

module Bushido
  class Data #:nodoc:
    
    extend Hooks

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

      
      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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bushido-0.0.35 lib/bushido/data.rb
bushido-0.0.34 lib/bushido/data.rb
bushido-0.0.33 lib/bushido/data.rb