morse_active_record_helpers 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06ddf469c0c0ef6aaa959eca6a21500ef3f39524
4
- data.tar.gz: a585a5a41ef62ffb9b14f3ea5e6f9330f0897238
3
+ metadata.gz: 071276d28946bc2425d11a2bc9629dffad761023
4
+ data.tar.gz: 6daef0c7405ced293dcc3a73dbdcf999aaa65eaa
5
5
  SHA512:
6
- metadata.gz: 6c6f0900f5a80adf0a40835231e21ff4c242fd45e446ae871a181d4ff61ddf1396517a7a2bdc79ef58b4247639812e19277430222316e3106d1594fca3506aa4
7
- data.tar.gz: d7f57909d7c1672daca776a06d6c7b6e01d7250f42fff0bf93b3b7abce676aa6ac9577f70bc6de64fef8d0560ad44ff0335df58e3593b082a13507d75b7b139f
6
+ metadata.gz: 352532876246984a221319bf77c2d1fcba5690b84d0a9f0edc7bbdc885a162e57d96e3a3f9ca04f4de71e6bcea134298ed9534f4092634f51b02648886ee4d7f
7
+ data.tar.gz: 5effcc3278b31123fb3625f94527dde1007232d529ca9951b2730c7508992a0f2d58925093b1791247b6baddeb9b8edba8205c4660324ad1cafa4f4f81392799
@@ -15,6 +15,7 @@ module MorseActiveRecordHelpers
15
15
  end
16
16
  end
17
17
 
18
+
18
19
  def correct_chronological_order(start, finish)
19
20
  if self.send(start) && self.send(finish)
20
21
  if self.send(start) > self.send(finish)
@@ -82,6 +83,19 @@ module MorseActiveRecordHelpers
82
83
  end
83
84
  end
84
85
 
86
+ def validate_legal_age(field, min=18)
87
+ if self.send(field).is_a?(Date)
88
+ unless self.send(field)<min.years.ago
89
+ errors.add(field.to_sym, "you are underage")
90
+ return false
91
+ end
92
+ else
93
+ errors.add(field.to_sym, "is not a valid date")
94
+ return false
95
+ end
96
+ end
97
+
98
+
85
99
  def validate_integer_or_default(thing,default)
86
100
  unless self.send(thing)
87
101
  self.send("#{thing}=",default)
@@ -1,3 +1,3 @@
1
1
  module MorseActiveRecordHelpers
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: morse_active_record_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Terry S
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-06 00:00:00.000000000 Z
11
+ date: 2015-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  version: '0'
135
135
  requirements: []
136
136
  rubyforge_project:
137
- rubygems_version: 2.4.8
137
+ rubygems_version: 2.4.5
138
138
  signing_key:
139
139
  specification_version: 4
140
140
  summary: Module to provide some nice helpers for Active Record Models