From 29db910861a6390ceda4c082aee1f003eb6055ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20Bo=CC=88ttger?= Date: Sun, 28 Apr 2013 22:22:19 +0200 Subject: [PATCH] keep it dry --- lib/aasm/persistence/base.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/aasm/persistence/base.rb b/lib/aasm/persistence/base.rb index b097df4..453a0ef 100644 --- a/lib/aasm/persistence/base.rb +++ b/lib/aasm/persistence/base.rb @@ -33,10 +33,11 @@ module AASM # # This allows for nil aasm states - be sure to add validation to your model def aasm_read_state + state = send(self.class.aasm_column) if new_record? - send(self.class.aasm_column).blank? ? aasm.determine_state_name(self.class.aasm_initial_state) : send(self.class.aasm_column).to_sym + state.blank? ? aasm.determine_state_name(self.class.aasm_initial_state) : state.to_sym else - send(self.class.aasm_column).nil? ? nil : send(self.class.aasm_column).to_sym + state.nil? ? nil : state.to_sym end end