Sha256: 81e1aae75419c9318dcf9be12ceb7593623b1c678c71be15f4cf8e413643afc0

Contents?: true

Size: 952 Bytes

Versions: 1

Compression:

Stored size: 952 Bytes

Contents

require "check_tag/version"
include ActionView::Helpers::FormTagHelper

module CheckTag
  def self.now(id, check=nil, uncheck=nil, defaulted=nil)
    begin
      @id = id
      @check = check
      @uncheck = uncheck
      @defaulted = defaulted
      defaults
      string_now
      hidden_tag = hidden_field_tag(@id, @uncheck)
      return_objects = check_box_tag(@id, @check, (@defaulted == @check ? true : false))
      return hidden_tag + " " + return_objects
    rescue
      puts "CHECK TAG ERROR.  You may have not have used all four arguments.  Usage: CheckTag.now('test_id', 'yes', 'no', 'no')"
    end  
  end
  
  def self.defaults
    if !@check
      @check = 'true'
    end
    if !@uncheck
      @uncheck = 'false'
    end  
    if !@defaulted
      @defaulted = @check
    end  
  end
  
  def self.string_now
    @id = @id.to_s
    @check = @check.to_s
    @uncheck = @uncheck.to_s
    @defaulted = @defaulted.to_s
  end
  
  
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
check_tag-0.0.4 lib/check_tag.rb