method_ni is a simple extension for ActiveRecord. You can easily store methods inside of records and evalute them on demand. I’ll give a short example:
In your model: class Service < ActiveRecord::Base has_method_in :custom_method validates_syntax_of :custom_method end In your controller: class OuterAccountsController < ApplicationController def create Service.create :custom_method => %{def one;1;end} end def show @service = Service.find(1) @service.apply_methods! @service.applied_methods => ["one"] result = @service.one end end
ruby script/plugin intall git://github.com/kairichard/method_ni.git
Tests can be run outside of Rails