obj.attribute
On bind, performs the binding routine using adapter.read
on the attribute if preloadData is set to true. Then calls adapter.subscribe
on the attribute.
obj:property
# MongoMapper::Document::InstanceMethods | |
def to_model | |
errors.instance_eval do | |
def [](attribute) | |
return [] if errors[attribute.to_sym].nil? | |
errors[attribute.to_sym] | |
end | |
end | |
self |
class Riak | |
include HTTParty | |
format :json | |
def self.config(host, port, prefix='riak') | |
base_uri "#{host}:#{port}/#{prefix}" | |
end | |
end |
" GENERAL | |
:set ruler | |
:set number | |
:set noswapfile | |
syntax on | |
colorscheme mr | |
" INDENTATION |
rivets.configure({ | |
adapter: { | |
subscribe: function(obj, keypath, callback) { | |
obj.on("change:" + keypath, callback); | |
}, | |
unsubscribe: function(obj, keypath, callback) { | |
obj.off("change:" + keypath, callback); | |
}, |
.done { | |
opacity: 0.5; | |
text-decoration: line-through; | |
} |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/' | |
} | |
export PS1="\[$(tput bold)\]\h:\W\$(parse_git_branch) $ \[$(tput sgr0)\]" |
function rmb { | |
current_branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') | |
if [ "$current_branch" != "master" ]; then | |
echo "WARNING: You are on branch $current_branch, NOT master." | |
fi | |
echo "Fetching merged branches..." | |
git remote prune origin | |
remote_branches=$(git branch -r --merged | grep -v '/master$' | grep -v "/$current_branch$") | |
local_branches=$(git branch --merged | grep -v 'master$' | grep -v "$current_branch$") | |
if [ -z "$remote_branches" ] && [ -z "$local_branches" ]; then |
One common pattern for nesting another model or collection inside a model is to assign it as a property on that object,
for example, @messages
on Mailbox
as illustrated on the Backbone.js homepage.
class Mailbox extends Backbone.Model
urlRoot: '/mailbox'
initialize: ->
function rp { | |
current_branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') | |
`git push origin $current_branch` | |
open `hub pull-request "$current_branch" -b coverall:$1` | |
} |