This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('.')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |