check_tag 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/check_tag/version.rb +1 -1
- data/lib/check_tag.rb +29 -8
- metadata +1 -1
data/lib/check_tag/version.rb
CHANGED
data/lib/check_tag.rb
CHANGED
@@ -2,20 +2,41 @@ require "check_tag/version"
|
|
2
2
|
include ActionView::Helpers::FormTagHelper
|
3
3
|
|
4
4
|
module CheckTag
|
5
|
-
def self.now(id, check, uncheck, defaulted)
|
5
|
+
def self.now(id, check=nil, uncheck=nil, defaulted=nil)
|
6
6
|
begin
|
7
|
-
id = id
|
8
|
-
check = check
|
9
|
-
uncheck = uncheck
|
10
|
-
defaulted = defaulted
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
@id = id
|
8
|
+
@check = check
|
9
|
+
@uncheck = uncheck
|
10
|
+
@defaulted = defaulted
|
11
|
+
defaults
|
12
|
+
string_now
|
13
|
+
hidden_tag = hidden_field_tag(@id, @uncheck)
|
14
|
+
return_objects = check_box_tag(@id, @check, (@defaulted == @check ? true : false))
|
15
|
+
return hidden_tag + " " + return_objects
|
14
16
|
rescue
|
15
17
|
puts "CHECK TAG ERROR. You may have not have used all four arguments. Usage: CheckTag.now('test_id', 'yes', 'no', 'no')"
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
21
|
+
def self.defaults
|
22
|
+
if !@check
|
23
|
+
@check = 'true'
|
24
|
+
end
|
25
|
+
if !@uncheck
|
26
|
+
@uncheck = 'false'
|
27
|
+
end
|
28
|
+
if !@defaulted
|
29
|
+
@defaulted = @check
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.string_now
|
34
|
+
@id = @id.to_s
|
35
|
+
@check = @check.to_s
|
36
|
+
@uncheck = @uncheck.to_s
|
37
|
+
@defaulted = @defaulted.to_s
|
38
|
+
end
|
39
|
+
|
19
40
|
|
20
41
|
|
21
42
|
end
|