neerajdotname-active_record_no_table 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,9 +1,15 @@
1
+ === 0.0.5 2009-07-09
1
2
 
3
+ * added the feature so that one could do mass assignment like @contact = Contact.new(params[:contact])
2
4
 
3
- === 0.0.3 2009-06-31
5
+ === 0.0.4 2009-06-31
4
6
 
5
7
  * fixing the bug regarding rails 2.3.x
6
8
 
9
+ === 0.0.3 2009-06-31
10
+
11
+ * fixing the bug regarding rails 2.2.x
12
+
7
13
  === 0.0.2 2009-06-31
8
14
 
9
15
  * fixing the bug regarding rails 2.1.x
data/README.markdown CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Using ActiveRecord validation utilitites is difficult if you do not have a table for your model. This gem makes it easy to use validation tools even if the model does not have a corresponding table.
4
4
 
5
+ This gem works with Rails 2.1 and higher.
6
+
5
7
  == How to install
6
8
 
7
9
  <pre>
@@ -24,19 +26,23 @@ config.gem "neerajdotname-active_record_no_table",
24
26
 
25
27
  <pre>
26
28
  <code>
27
- class User < ActiveRecord::NoTable
28
- validates_presence_of :name
29
- attr_accessor :name
29
+ class Contact < ActiveRecord::NoTable
30
+ attr_accessor :name, :email, :body, :subject
31
+ validates_presence_of :name, :email, :body
32
+ validates_format_of :email,
33
+ :with => Format::EMAIL,
34
+ :message => "^The email address is not valid. Please enter a valid email address.",
35
+ :if => Proc.new { |record| record.email.not_blank?}
30
36
  end
31
37
 
32
- >> user = User.new
33
- >> user.valid?
34
- >> user.errors.full_messages
35
- >> ["Name can't be blank"]
38
+ # in controller
39
+ @contact = Contact.new(params[:contact])
40
+ if @contact.valid?
41
+ ...
42
+ end
36
43
  </code>
37
44
  </pre>
38
45
 
39
-
40
46
  == Feedback
41
47
 
42
48
  Email me: neerajdotname [at] gmail (dot) com
@@ -6,6 +6,12 @@ require 'rubygems'
6
6
 
7
7
  module Validateable_2_1
8
8
  [:save, :save!, :update_attribute].each{|attr| define_method(attr){}}
9
+
10
+ def initialize(options={})
11
+ options.each do |k,v|
12
+ self.send(k.to_s+'=',v) rescue nil
13
+ end
14
+ end
9
15
 
10
16
  def method_missing(symbol, *params)
11
17
  if(symbol.to_s =~ /(.*)_before_type_cast$/)
@@ -32,6 +38,12 @@ end
32
38
  module Validateable_2_2
33
39
 
34
40
  [:save, :save!, :update_attribute].each{|attr| define_method(attr){}}
41
+
42
+ def initialize(options={})
43
+ options.each do |k,v|
44
+ self.send(k.to_s+'=',v) rescue nil
45
+ end
46
+ end
35
47
 
36
48
  def method_missing(symbol, *params)
37
49
  if(symbol.to_s =~ /(.*)_before_type_cast$/)
@@ -85,6 +97,12 @@ end
85
97
  module Validateable_2_3
86
98
 
87
99
  [:save, :save!, :update_attribute].each{|attr| define_method(attr){}}
100
+
101
+ def initialize(options={})
102
+ options.each do |k,v|
103
+ self.send(k.to_s+'=',v) rescue nil
104
+ end
105
+ end
88
106
 
89
107
  def method_missing(symbol, *params)
90
108
  if(symbol.to_s =~ /(.*)_before_type_cast$/)
@@ -99,7 +117,6 @@ module Validateable_2_3
99
117
 
100
118
  base.send :include, ActiveSupport::Callbacks
101
119
  base.define_callbacks *ActiveRecord::Validations::VALIDATIONS
102
-
103
120
  end
104
121
 
105
122
  module ClassMethods
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neerajdotname-active_record_no_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neeraj Singh
@@ -31,7 +31,7 @@ files:
31
31
  - lib/active_record_no_table.rb
32
32
  has_rdoc: false
33
33
  homepage: http://github.com/neerajdotname/active_record_no_table
34
- post_install_message: PostInstall.txt
34
+ post_install_message: README.markdown
35
35
  rdoc_options:
36
36
  - --main
37
37
  - README.markdown