public
Fork of brennandunn/preference_fu
Description: Allows the storage of a number of boolean fields with just one table column
Homepage: http://www.brennandunn.com
Clone URL: git://github.com/dynamix/preference_fu.git
added easy preference accessor : like xyz.send_email? for :send_email 
preference. added preference to bitmask method.
dynamix (author)
Tue May 20 00:45:48 -0700 2008
commit  e2ca7f0fa788cb221b208a428abc747a14e82fe7
tree    92c490bb86c58dbade803ded53c5f925f3fdeeac
parent  c47a0693b9915db24ea1901260a99ab050dbd1a9
...
9
10
11
 
 
 
 
 
12
13
14
...
99
100
101
 
 
 
 
 
 
 
 
 
 
102
103
104
...
9
10
11
12
13
14
15
16
17
18
19
...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
0
@@ -9,6 +9,11 @@ module PreferenceFu
0
   
0
   module ClassMethods
0
     
0
+ def preference_to_bitmask(preference)
0
+ self.preference_options.each_key { |k| return k if self.preference_options[k][:key] == preference}
0
+ return 0
0
+ end
0
+
0
     def has_preferences(*options)
0
       alias_method_chain :initialize, :preferences
0
       
0
@@ -99,6 +104,16 @@ module PreferenceFu
0
       
0
     end
0
     
0
+ def method_missing(name,*args)
0
+ name = name.to_s
0
+ instance_variable_name = "@" + name[0..-2]
0
+ if name[-1] == ?? and instance_variable_defined?(instance_variable_name)
0
+ return instance_variable_get(instance_variable_name)
0
+ else
0
+ super
0
+ end
0
+ end
0
+
0
     def each
0
       @options.each_value do |hsh|
0
         yield hsh[:key], self[hsh[:key]]

Comments

    No one has commented yet.