From b4c79b08a295e4f57d79d0a41bfe9417ff03f489 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Wed, 11 May 2016 12:12:33 -0400 Subject: [PATCH] Bring Back The Magic --- app/models/customer.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/models/customer.rb b/app/models/customer.rb index 9e2f13c..22e6260 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -90,6 +90,24 @@ class Customer < ActiveRecord::Base @details.notes = s if @details end + # Magic Method + def method_missing(name, *arguments) + value = arguments[0] + name = name.to_s + + # if the method's name ends with '=' + if name[-1, 1] == "=" + method_name = name[0..-2] + @details[method_name] = value + else + begin + return @details[name] + rescue + return nil + end + end + end + # proforms a bruteforce sync operation # This needs to be simplified def self.sync