Skip to content

Instantly share code, notes, and snippets.

export PS1='\[\033[01;32m\]\w $(git branch &>/dev/null; if [ $? -eq 0 ]; then echo "\[\033[01;34m\]$(git branch | grep '^*' |sed s/\*\ //)"; fi) \$ \[\033[00m\]'
merb_auth_routes(:name_prefix => nil, :path_prefix => "") do
match("/openid").to(:controller => "merb_auth_slice_password/sessions", :action => "update").name(:openid)
end
given "logged in" do
login
end
context "when logged in" do
context "Homepage: url(:home)", :given => "logged in" do
before(:each) do
@rack = request(:home)
end
New entry posted to the journal:
= self.params[:entry].body
# authorize :some_label => ["list", "of", "strategies"]
class Post
authorize :edit => ["my_strategy", "another_one"],
:create => "some_other_strategy",
:view => "view_strategy"
end
class Article
include DataMapper::Resource
authorizable!
authorize_with do
with(:view ).use(:Public, :ViewPublished, :Admin, :PublisherRole)
with(:view_draft).use(:Owner, :PublisherRole, :Admin)
with(:edit ).use(:Owner, :Admin)
with(:create ).use(:Public)
with(:delete ).use(:Admin)
# This file is specifically for you to define your strategies
#
# You should declare you strategies directly and/or use
# Merb::Authentication.activate!(:label_of_strategy)
#
# To load and set the order of strategy processing
Merb::Slices::config[:"merb-auth-slice-password"][:no_default_strategies] = true
module Merb::Authentication::Strategies
class Merb::Authorization
operator_classes User, Staff, Customer, Group, String, Hash
operator_aliases :can?, is?, :authorized_for?, :authorized_to?, :authorized_with?
end
## The aliases allow for
user.authorized?
user.can?
user.is?
function(doc) {
if ( doc["couchrest-type"] == "Account" ) {
emit(doc._id, ["Account", doc]);
}
if ( doc["couchrest-type"] == "Contact" ) {
emit(doc.account_id, ["Contact", doc]);
}
}
require 'benchmark'
class Foo
attr_accessor :the_blocks, :method_map
class Bar
def bar
:bar
end
end