app/helpers/application_helper.rb
#
# Returns the blank_label method output
# if the path to the value is invalid or blank
# Can specify a different default value by supplying a block
#
# def_if_blank(feature_name, :type, :name)
# def_if_blank(feature_name, :type, :name){'-'}
#
Returns the blank_label method output
if the path to the value is invalid or blank
Can specify a different default value by supplying a block


Returns the blank_label method output if the path to the value is invalid or blank Can specify a different default value by supplying a block
def def_if_blank(*resource_path)
    default = block_given? ? yield : blank_label
    obj = resource_path.shift
    resource_path.each do |method|
      return default if ! obj.respond_to?(method)
      current = obj.send(method)
      return default if current.to_s.blank?
      obj = current
    end
    obj
  end
def def_if_blank ( * resource_path ) default = block_given? ? yield : blank_label obj = resource_path . shift resource_path . each do | method | return default if ! obj . respond_to? ( method ) current = obj . send ( method ) return default if current . to_s . blank? obj = current end obj end
Returns the blank_label method output
if the path to the value is invalid or blank
Can specify a different default value by supplying a block
Returns the blank_label method output if the path to the value is invalid or blank Can specify a different default value by supplying a block
resource_path
<not_specific>