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 +4 -4
- data/lib/morse_active_record_helpers.rb +14 -0
- data/lib/morse_active_record_helpers/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 071276d28946bc2425d11a2bc9629dffad761023
|
4
|
+
data.tar.gz: 6daef0c7405ced293dcc3a73dbdcf999aaa65eaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
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.
|
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-
|
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.
|
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
|