Skip to content

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

Notifications You must be signed in to change notification settings

oleriesenberg/method_ni

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages