Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kairichard/method_ni

This is a simple plugin which supports "class/instance.methods" being held inside of records
https://github.com/kairichard/method_ni

Last synced: 1 day ago
JSON representation

This is a simple plugin which supports "class/instance.methods" being held inside of records

Awesome Lists containing this project

README

        

= method_ni

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:

= Usage
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

= Install
ruby script/plugin intall git://github.com/kairichard/method_ni.git

= Misc
Tests can be run outside of Rails