Skip to content

Instantly share code, notes, and snippets.

View beerlington's full-sized avatar

Peter Brown beerlington

View GitHub Profile
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
Constant.find_all_by_global(true).each do |c|
@system_constants.class_eval do
define_method c.name.fieldize, lambda { detect {|sc| sc.constant.name == c.name}.instance_eval { {:value => value, :unit => c.unit} } }
end
end unless @system_constants.empty?
module ClassyEnumHelper
class SemanticFormBuilder < Formtastic::SemanticFormBuilder
def enum_select_input(method, options)
enum_class = object.send(method)
unless enum_class.respond_to? :base_class
raise "#{method} does not refer to a defined ClassyEnum object"
end
options[:collection] = enum_class.base_class.all_with_name