simple_model 0.1.5 → 0.1.6

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/lib/simple_model.rb CHANGED
@@ -25,4 +25,5 @@ module SimpleModel
25
25
  include SimpleModel::Validation
26
26
  end
27
27
  end
28
+
28
29
  end
@@ -53,10 +53,11 @@ module SimpleModel
53
53
 
54
54
  module ClassMethods
55
55
  def has_attributes(*attrs)
56
+ options = attrs.extract_options!
56
57
  attrs.each do |attr|
57
58
 
58
59
  attr_reader attr
59
-
60
+ define_reader_with_options(attr,options)
60
61
  define_method("#{attr.to_s}=") do |val|
61
62
  instance_variable_set("@#{attr}", val)
62
63
  attributes[attr] = val
@@ -26,6 +26,7 @@ module SimpleModel
26
26
  end
27
27
  end
28
28
  end
29
+
29
30
  def validates_length_of(*attr_names)
30
31
  options = attr_names.extract_options!
31
32
 
@@ -34,9 +35,9 @@ module SimpleModel
34
35
 
35
36
  att_method = send(attr)
36
37
  unless att_method.blank?
37
- errors.add(attr,(options[:message].blank? ? "must equal #{options[:equal]} characters in length." : options[:message])) if options[:equal] && att_method.to_s.length != options[:equal]
38
- errors.add(attr,(options[:message].blank? ? "cannot have more than #{options[:max]} characters in length." : options[:message])) if options[:max] && att_method.to_s.length > options[:max]
39
- errors.add(attr,(options[:message].blank? ? "cannot have less than #{options[:min]} characters in length." : options[:message])) if options[:min] && att_method.to_s.length < options[:min]
38
+ errors.add(attr,(options[:message].blank? ? "must equal #{options[:is]} characters in length." : options[:message])) if options[:is] && att_method.to_s.length != options[:is]
39
+ errors.add(attr,(options[:message].blank? ? "cannot have more than #{options[:maximum]} characters in length." : options[:message])) if options[:maximum] && att_method.to_s.length > options[:maximum]
40
+ errors.add(attr,(options[:message].blank? ? "cannot have less than #{options[:minimum]} characters in length." : options[:message])) if options[:minimum] && att_method.to_s.length < options[:minimum]
40
41
  end
41
42
  end
42
43
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleModel
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 5
9
- version: 0.1.5
8
+ - 6
9
+ version: 0.1.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Joshua T Mckinney
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-02 00:00:00 -06:00
17
+ date: 2011-02-03 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency