This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DS.rejectionHandler = function(reason) { | |
if (reason.status === 401) { | |
App.Auth.destroy(); | |
} | |
throw reason; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.AuthenticatedRESTAdapter = DS.RESTAdapter.extend({ | |
ajax: function(url, type, hash) { | |
hash = hash || {}; | |
hash.headers = hash.headers || {}; | |
hash.headers['X-AUTHENTICATION-TOKEN'] = this.authToken; | |
return this._super(url, type, hash); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
session: { | |
auth_token: '<SOME RANDOM AUTH TOKEN>', | |
account_id: '<ID OF AUTHENTICATED USER>' | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.SessionsNewRoute = Ember.Route.extend({ | |
events: { | |
createSession: function() { | |
var router = this; | |
var loginOrEmail = this.controller.get('loginOrEmail'); | |
var password = this.controller.get('password'); | |
if (!Ember.isEmpty(loginOrEmail) && !Ember.isEmpty(password)) { | |
$.post('/session', { | |
session: { login_or_email: loginOrEmail, password: password } | |
}, function(data) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'uri' | |
lang = 'ruby' | |
code = 'class Test; end' | |
response = Net::HTTP.post_form(URI.parse('https://pygments.simplabs.com/'), { 'lang' => lang, 'code' => code }) | |
puts response.body |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Broker | |
class Server < Goliath::API | |
use Goliath::Rack::Heartbeat | |
use Goliath::Rack::SimpleAroundwareFactory, Broker::LoggingAroundware | |
def response(env) | |
url = "app_server:3000#{env['REQUEST_URI']}" | |
method = env['REQUEST_METHOD'].downcase.to_sym |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Product < ActiveRecord::Base | |
belongs_to :product | |
include Module.new do | |
def product=(product) | |
super | |
freeze_product_data | |
product |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Product < ActiveRecord::Base | |
belongs_to :product | |
def product=(product) | |
super | |
freeze_product_data | |
product | |
end |