This file contains 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
Privilege # ensure that Privilege class is loaded | |
# This module provides access control behavior to ActiveRecord models. | |
# The class into which it is included must provide a '#client' method | |
# the result of which will be used as the context for authorization | |
# checks. | |
module AccessControl | |
# Indicates if +an_account+ is allowed to know of the existence of this | |
# object. |
This file contains 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
Merb::ControllerExceptions::STATUS_CODES.each do |name, code| | |
reason_phrase = name.to_s.split('_').map{|s| s.capitalize}.join(' ') | |
Spec::Matchers.create("be_#{name}") do | |
matches do |resp| | |
@status = resp.status | |
@status == code | |
end | |
message do |not_string, resp| |
This file contains 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
http://core.ssbe.localhost/clients | |
{ | |
"href": "http://core.ssbe.localhost/clients", | |
"item_count": 2, | |
"items": [ | |
{ | |
"_type": "Client", | |
"href": "http://core.ssbe.localhost/clients/API", | |
"id": "490a167b-c725-49e3-a917-2a5f5a486b4a", | |
"name": "API", |
This file contains 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 SsbeQueryExtensions | |
attr_accessor :collection_uri | |
end | |
module SsbeModelExtensions | |
def collection(uri, query = {}) | |
query = Query.new(self.repository, self) | |
query.extend(SsbeQueryExtensions) | |
query.collection_uri = uri |
This file contains 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 DataMapper | |
module SsbeQueryExtensions | |
def self.extended(base) | |
(class << base; self; end).send(:attr_accessor, :collection_uri) | |
end | |
end |
This file contains 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
% ab -n10000 localhost:4000/orm/exception | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking localhost (be patient) | |
Completed 1000 requests | |
Completed 2000 requests | |
Completed 3000 requests | |
Completed 4000 requests |
This file contains 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 File.join(File.dirname(__FILE__), 'host_shared_specs') | |
describe 'POST SSMJ1 to /client/x/hosts', :type => 'service' do | |
request { |attributes| | |
post_ssmj1(hosts_by_client_url(attributes[:client] || Client::API), | |
host_ssmj1_json(attributes)) | |
} | |
should_be_created |
This file contains 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
// core.ssbe.localhost/clients/legacy_client | |
{ | |
"_type": "Client", | |
"href": "http://core.ssbe.localhost/clients/legacy_client", | |
"id": "cecbab41-59cb-46fc-89e6-7d49ec60ccbe", | |
"name": "legacy_client", | |
"parent_href": "http://core.ssbe.localhost/clients/API", | |
"hosts_href": "http://core.ssbe.localhost/clients/legacy_client/hosts" | |
} | |
This file contains 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 Exceptions < Application | |
skip_before :parse_supplied_sscj1 | |
skip_before :ensure_authenticated | |
provides :sscj1 | |
# ... | |
# handle RecordInvalid exceptions (406) | |
def record_invalid |
This file contains 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
DO_POSTGRES | POSTGRES | VS | AR | | |
--Reading---------------------------------------------------- | |
SELECT * 6.865 | 7.004 | 0.98x | 10.309 | |