Module: ActionView::Helpers::InstanceTagMethods::ClassMethods

Defined in:
lib/action_view/helpers/form_helper.rb

Instance Method Summary collapse

Instance Method Details

#check_box_checked?(value, checked_value) ⇒ Boolean

Returns:

  • (Boolean)


1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
# File 'lib/action_view/helpers/form_helper.rb', line 1026

def check_box_checked?(value, checked_value)
  case value
  when TrueClass, FalseClass
    value
  when NilClass
    false
  when Integer
    value != 0
  when String
    value == checked_value
  when Array
    value.include?(checked_value)
  else
    value.to_i != 0
  end
end

#radio_button_checked?(value, checked_value) ⇒ Boolean

Returns:

  • (Boolean)


1043
1044
1045
# File 'lib/action_view/helpers/form_helper.rb', line 1043

def radio_button_checked?(value, checked_value)
  value.to_s == checked_value.to_s
end

#value(object, method_name) ⇒ Object



1014
1015
1016
# File 'lib/action_view/helpers/form_helper.rb', line 1014

def value(object, method_name)
  object.send method_name unless object.nil?
end

#value_before_type_cast(object, method_name) ⇒ Object



1018
1019
1020
1021
1022
1023
1024
# File 'lib/action_view/helpers/form_helper.rb', line 1018

def value_before_type_cast(object, method_name)
  unless object.nil?
    object.respond_to?(method_name + "_before_type_cast") ?
    object.send(method_name + "_before_type_cast") :
    object.send(method_name)
  end
end