Mapper#loader(body) => [Loader] # Loader for specific body
Mapper#dumper(object) => [Dumper] # Dumper for object
Mapper#execute(command) # command is an instance of DataMapper::Session::Command::{Insert,Update,Delete}
Loader#identity => [Identity] # Any mapper specific object that implements#hash
Loader#object => [Object] # The loaded domain object
class Foo | |
def bar | |
:baz | |
end | |
end |
class ControllerSource | |
Response = Struct.new(:controller, :injector) do | |
def redirect_to(path, *args) | |
controller.redirect_to(controller.send("#{path}_path", *args)) | |
end | |
def render(*args) | |
ivars = {} | |
if args.last.is_a?(Hash) && args.last.has_key?(:ivars) | |
ivars = args.last.delete(:ivars) |
git remote update && | |
git remote prune origin && | |
git branch -r --merged origin/master | | |
awk -F"/" '!/(>|master)/ {print $2}' | | |
xargs -rL1 git push origin --delete |
require 'memoist' | |
# Usage: | |
# | |
# customers = Customer.preload(Customer.orders.line_items.item) | |
# | |
# customers.each do |customer| | |
# customer.orders.each do |order| | |
# order.line_items.each do |line_item| | |
# line_item.item # yay, no more N+1, only 4 queries executed ! |
# This is a mapper I created when I was in hurry/spiking using: | |
# github.com/mbj/mapper (a stupid try-to-be-most-generic mapper implementation, to be rewritten) | |
# github.com/mbj/session (a database session/IdentityMap that can possibly work with any (document) mapper) | |
# the Session thing is more or less stable, and I like it! | |
# This code is not used anymore, it was replaced by a non generic application specific mapper to elasticsearch. | |
# Also this code never went to production. | |
# The whole point of this literal mess was to transform a tree of objects into a document that could be stored within mongo. | |
# The virtus object tree should be reconstructed 1:1. |
Recently, we've been working on extracting Ember conventions from applications we're working on into the framework. Our goal is to make it clearer how the parts of an Ember application work together, and how to organize and bootstrap your objects.
Routing is an important part of web applications. It allows your users to share the URL they see in their browser, and have the same things appear when their friends click on the link.
The Ember.js ecosystem has several great solutions for routing. But, since it is such an important part of most web applications, we've decided to build it right into the framework.
If you have already modeled your application state using Ember.StateManager
, there are a few changes you'll need to make to enable routing. Once you've made those changes, you'll notice the browser's address bar spring to life as you start using your app—just by moving between states, Ember.js will update the URL automatically.
-- PostgreSQL 9.2 beta (for the new JSON datatype) | |
-- You can actually use an earlier version and a TEXT type too | |
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8 | |
-- Inspired by | |
-- http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html | |
-- http://ssql-pgaustin.herokuapp.com/#1 | |
-- JSON Types need to be mapped into corresponding PG types | |
-- |
require 'sinatra/base' | |
require 'http_router_sinatra' | |
# With this simplistic approach, Sinatra apps must be leaf nodes in the rack graph | |
# Mounter nodes may be nested arbitrarily deeply however. | |
# Include Warden to authenticate whole sub-branches of the graph | |
class Mounter < HttpRouter | |
def mount(path, app) | |
route = add(path).partial.to(app) | |
mounter = app.respond_to?(:url_mount) ? app : nil |
## | |
## with raw object | |
## | |
# create a new object | |
o = Object.new | |
# define methods on the object (precisely, the object's singleton) | |
class << o | |
def hello(thing) |