GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Fork of vigetlabs/profile_validator
Description: Associate models with profiles on other websites
Clone URL: git://github.com/dce/profile_validator.git
Moved profile_validator into Viget module
dce (author)
Tue Jul 15 13:35:49 -0700 2008
commit  66197a5574fc53de00323de80b08ac3c03da37ea
tree    562a1ca0f652ca9691bdf0a454d1be157e4cfdb8
parent  ba1c008180e3e5e9f6d28c10efbad0b7213d1a1c
...
1
2
3
4
 
...
1
2
 
3
4
0
@@ -1,3 +1,3 @@
0
 # Include hook code here
0
 require File.dirname(__FILE__) + '/lib/profile_validator'
0
-ActiveRecord::Base.send :include, ProfileValidator
0
\ No newline at end of file
0
+ActiveRecord::Base.send :include, Viget::ProfileValidator
...
1
2
3
4
5
 
 
 
 
 
 
 
6
7
 
 
8
9
10
11
12
13
 
 
 
14
15
16
17
18
19
 
 
 
 
 
20
21
22
23
24
 
 
 
 
 
 
 
25
26
27
28
29
 
30
31
 
 
 
32
33
34
35
36
37
38
39
40
...
 
 
 
 
 
1
2
3
4
5
6
7
8
 
9
10
11
 
 
 
 
 
12
13
14
15
 
 
 
 
 
16
17
18
19
20
21
 
 
 
 
22
23
24
25
26
27
28
29
 
30
31
 
32
33
 
34
35
36
37
 
 
38
 
39
 
40
41
0
@@ -1,39 +1,40 @@
0
-module ProfileValidator
0
-
0
- def self.included(base)
0
- base.class_eval do
0
- base.extend ClassMethods
0
+module Viget
0
+ module ProfileValidator
0
+
0
+ def self.included(base)
0
+ base.class_eval do
0
+ base.extend ClassMethods
0
+ end
0
     end
0
- end
0
+
0
+ module ClassMethods
0
 
0
- module ClassMethods
0
-
0
- def validates_profile(options = {})
0
- association_options = { :as => :profileable }
0
- association_options[:class_name] = options[:site].camelcase + 'Profile' if options[:site]
0
+ def validates_profile(options = {})
0
+ association_options = { :as => :profileable }
0
+ association_options[:class_name] = options[:site].camelcase + 'Profile' if options[:site]
0
 
0
- if options[:multiple]
0
- has_many :profiles, association_options
0
- else
0
- has_one :profile, association_options
0
- end
0
+ if options[:multiple]
0
+ has_many :profiles, association_options
0
+ else
0
+ has_one :profile, association_options
0
+ end
0
 
0
- class_inheritable_reader :url_format
0
- format = options[:url_format]
0
- format = [format || /^https?:\/\/\w{2,}\.\w{2,}/] unless format.is_a?(Array)
0
- write_inheritable_attribute(:url_format, format)
0
+ class_inheritable_reader :url_format
0
+ format = options[:url_format]
0
+ format = [format || /^https?:\/\/\w{2,}\.\w{2,}/] unless format.is_a?(Array)
0
+ write_inheritable_attribute(:url_format, format)
0
+
0
+ include InstanceMethods
0
+ end
0
 
0
- include InstanceMethods
0
     end
0
     
0
- end
0
+ module InstanceMethods
0
   
0
- module InstanceMethods
0
+ def url_for_profile
0
+ "http://example.com/#{self.id}"
0
+ end
0
 
0
- def url_for_profile
0
- "http://example.com/#{self.id}"
0
     end
0
-
0
   end
0
-
0
 end
0
\ No newline at end of file
...
1
 
2
3
4
...
46
47
48
49
50
 
...
 
1
2
3
4
...
46
47
48
 
49
50
0
@@ -1,4 +1,4 @@
0
-unless defined?(ProfileValidator)
0
+unless defined?(Viget::ProfileValidator)
0
   require 'rubygems'
0
   require 'active_record'
0
   require 'test/unit'
0
@@ -46,4 +46,4 @@ unless defined?(ProfileValidator)
0
     validates_profile :multiple => true
0
   end
0
 
0
-end
0
\ No newline at end of file
0
+end

Comments

    No one has commented yet.