Permalink
Browse files

Moved instance methods out of module

  • Loading branch information...
1 parent ebcfceb commit cac5c068904e83e1fab883f1e7dc6a327ef39396 @dkastner committed Jul 13, 2010
Showing with 12 additions and 13 deletions.
  1. +12 −13 lib/falls_back_on.rb
View
@@ -2,28 +2,16 @@ module FallsBackOn
def falls_back_on(options = {})
class_eval do
class_inheritable_accessor :fallback_options
- # include FallsBackOn::InstanceMethods
end
self.fallback_options = options
extend FallsBackOn::InstanceMethods
end
-
+
module InstanceMethods
def fallback
Fallback.get_for(class_name)
end
- def destroy_fallback
- Fallback.destroy_for(class_name)
- end
-
- def set_fallback
- values = {}
- values = values.merge(fallback_value_for_name) if column_names.include?('name')
- values = fallback_options.keys.inject({}) { |memo, k| memo.merge(k => fallback_value_for(k)) }
- Fallback.set_for(class_name, values)
- end
-
def fallback_value_for(k)
v = fallback_options[k]
case v
@@ -47,5 +35,16 @@ def fallback_value_for_random(k)
return fallback_value_for_random(k) unless send("find_by_#{k}", random).nil?
random
end
+
+ def destroy_fallback
+ Fallback.destroy_for(class_name)
+ end
+
+ def set_fallback
+ values = {}
+ values = values.merge(fallback_value_for_name) if column_names.include?('name')
+ values = fallback_options.keys.inject({}) { |memo, k| memo.merge(k => fallback_value_for(k)) }
+ Fallback.set_for(class_name, values)
+ end
end
end

0 comments on commit cac5c06

Please sign in to comment.