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)


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

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)


1040
1041
1042
# File 'lib/action_view/helpers/form_helper.rb', line 1040

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

#value(object, method_name) ⇒ Object



1011
1012
1013
# File 'lib/action_view/helpers/form_helper.rb', line 1011

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

#value_before_type_cast(object, method_name) ⇒ Object



1015
1016
1017
1018
1019
1020
1021
# File 'lib/action_view/helpers/form_helper.rb', line 1015

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