public
Description: object-oriented activerecord validations and machine/human formatting
Clone URL: git://github.com/cainlevy/semantic-attributes.git
Search Repo:
more robust implementation of inheritable attributes, for rails 2.1 compat
cainlevy (author)
Thu Jun 26 13:41:20 -0700 2008
commit  c937459bc8624b60d524160985d38f0686c8db25
tree    8dc55d94484dbfe0614587193cf7f8a5b889aa1e
parent  a374aa30b0936ea2047db45ca19ec0b9d4917a03
...
8
9
10
11
12
13
14
15
16
 
 
 
 
17
18
19
...
67
68
69
 
 
 
 
70
71
72
...
8
9
10
 
 
 
11
12
13
14
15
16
17
18
19
20
...
68
69
70
71
72
73
74
75
76
77
0
@@ -8,12 +8,13 @@ module ActiveRecord
0
         attribute_method_suffix '_valid?'
0
 
0
         validate :validate_predicates
0
-
0
- class_inheritable_reader :semantic_attributes
0
- write_inheritable_attribute :semantic_attributes, SemanticAttributes.new
0
       end
0
     end
0
 
0
+ def semantic_attributes
0
+ self.class.semantic_attributes
0
+ end
0
+
0
     # the validation hook that checks all predicates
0
     def validate_predicates
0
       semantic_attributes.each do |attribute|
0
@@ -67,6 +68,10 @@ module ActiveRecord
0
     end
0
 
0
     module ClassMethods
0
+ def semantic_attributes
0
+ read_inheritable_attribute(:semantic_attributes) || write_inheritable_attribute(:semantic_attributes, SemanticAttributes.new)
0
+ end
0
+
0
       # Provides sugary syntax for adding and querying predicates
0
       #
0
       # The syntax supports the following forms:

Comments

    No one has commented yet.