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.
@@ -1,3 +1,3 @@
1
1
  module CheckTag
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
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.to_s
8
- check = check.to_s
9
- uncheck = uncheck.to_s
10
- defaulted = defaulted.to_s
11
- @hidden_tag = hidden_field_tag(id, uncheck)
12
- @return_objects = check_box_tag(id, check, (defaulted == check ? true : false))
13
- return @hidden_tag + " " + @return_objects
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: check_tag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: