Flowdock

Notes posted by lakesare

RSS feed
April 8, 2015 - (v3.1.0 - v4.1.8)
1 thank

What object_name.method values will result in checked chekboxes.

*It’s intended that method returns an integer and if that integer is above zero, then the checkbox is checked.* - more exactly, that’s how it’s determined whether value will be checked or not:

(`@checked_value` is checked_value, `value` is what object_name.method returns)

def checked?(value)
  case value
  when TrueClass, FalseClass 
    value == !!@checked_value
  when NilClass
    false
  when String
    value == @checked_value
  else
    if value.respond_to?(:include?)
      value.include?(@checked_value)
    else
      value.to_i == @checked_value.to_i
    end
  end
end