Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- attributes.each_key do | key |
- name = key
- alias_attribute key.to_sym, key[0, (key.length -2)].to_sym if key =~ /_c$/
- end
- attributes.each_key do | key |
- name = key
- alias_attribute key.to_sym, key[0, (key.length -2)].to_sym if key =~ /_c$/
- end
- attributes
- methods.each do |method|
- if method.ends_with("_c") then
- self.send(:defind_method,method.slice(0,-2)){self.send(method)}
- end
- end
- module ShittyDatabaseMethods
- alias :old_method_missing :method_missing
- def method_missing(method)
- if methods.include?("#{method}_c")
- send("#{method}_c".to_sym)
- else
- old_method_missing(method)
- end
- end
- end
- class Test
- attr_accessor :test_c
- include ShittyDatabaseMethods
- end
Add Comment
Please, Sign In to add comment