lib/archiveable.rb in archiveable-0.0.5 vs lib/archiveable.rb in archiveable-0.0.6

- old
+ new

@@ -13,19 +13,19 @@ def published !archived end def published=(value) - self.archived = !value + self.archived = !bool(value) end def archived archived_at.present? end def archived=(value) - self.archived_at = value ? Time.now : nil + self.archived_at = bool(value) ? Time.now : nil end def archive update archived: true end @@ -38,7 +38,13 @@ update archived: false end def publish! update! archived: false + end + + private + + def bool(value) + not ["false", "0", ""].include? value.to_s.downcase end end