A proof of concept of having Sinatra like routes inside your controllers.
Since the router is gone, feel free to remove config/routes.rb
.
Then add the file below to lib/action_controller/inline_routes.rb
inside your app.
curry = (fn)-> | |
slice = Array.prototype.slice | |
args = slice.apply arguments, [1] | |
return -> | |
fn.apply null, args.concat(slice.apply arguments) | |
levenshteinD = (s,t) -> | |
if !s.length then return t.length | |
if !t.length then return s.length |
[transcript from http://www.youtube.com/watch?v=z73uiWKdJhw and irc]
Timing - middle of the day US
$VERBOSE = nil | |
require File.expand_path('../rooby', __FILE__) | |
Person = Rooby::Class.new 'Person' do | |
define :initialize do |name| | |
@name = name | |
end | |
define :name do |
libs = ARGV.size == 0 ? all_gems : ARGV | |
list = | |
libs. | |
forkify(16){|lib| puts "#{ lib }..."; [lib, polluted_by(lib)]}. | |
sort_by{|pair| pair.last} | |
list.each do |lib, polluted| | |
puts "polluted_by('#{ lib }') #=> #{ polluted }" |
// | |
var Grid = new Function(); | |
Grid.initialize = function(){ | |
var args = Array.prototype.slice.apply(arguments); | |
var grid = new Grid(); | |
grid.initialize.apply(grid, args); |
#!/usr/bin/env rake | |
require 'rspec/core/rake_task' | |
RSpec::Core::RakeTask.new(:spec => :dummy_app) do |t| | |
t.pattern = File.expand_path('../spec/**/*_spec.rb', __FILE__) | |
end | |
task :default => :spec | |
desc 'Generates a dummy app for testing' | |
task :dummy_app => [:setup, :migrate] |
# Since CoffeeScript wraps everything in a closure by default, the module | |
# definition function pattern that Marionette normally uses is unnecessary. | |
# (And cumbersome with having to indent everything.) Instead, creating the | |
# module at the very begining makes it available to everything in the file, and | |
# the initializers and exported classes can be added at the end of the file. | |
# (This relies on things like the App and Backbone being on window, but they | |
# already have to be for CoffeeScript-based code to work.) | |
# Create the module. | |
Foo = App.module 'Foo' |
require 'rubygems' | |
require 'benchmark/ips' | |
class ExampleClass | |
def foo; 42; end | |
end | |
module ExampleMixin | |
def foo; 43; end | |
end |
One of the problems with advancing the discussion on DCI is that we lack a comparable alternative pattern that has the same goals, but favors a low ceremony approach. The closest thing we have to that is Rails concerns, but they are more like distant relatives of the DCI concepts rather than first cousins, and that makes comparisions between the two approaches not especially fruitful.
I am considering the idea of experimenting with my own paradigm that captures the intent and purity of DCI, but with the convenience of concerns. Please note that this is just the starting point of a conversation, it is NOT a promise of comercially available cold fusion or a cure for cancer. It's just a gist with an idea on it I'd like to hear your thoughts on.
What if we had a top-level topology that was split into Models, **Rol