def humanize(lower_case_and_underscored_word, options = {})
      result = lower_case_and_underscored_word.to_s.dup

      # no humans attr exists on inflections, need to port that over

      # opal - string mutation
      inflections.humans.each { |(rule, replacement)| break if (result = result.sub(rule, replacement)) }

      # opal - \A and \z not supported
      #result = result.sub(/\A_+/, ''.freeze)
      result = result.sub(/^_+/, ''.freeze)
      #result = result.sub(/_id\z/, ''.freeze)
      result = result.sub(/_id$/, ''.freeze)
      result = result.tr('_'.freeze, ' '.freeze)

      result = result.gsub(/([a-z\d]*)/i) do |match|
        "#{inflections.acronyms[match] || match.downcase}"
      end

      if options.fetch(:capitalize, true)
        #result = result.sub(/\A\w/) { |match| match.upcase }
        result = result.sub(/^\w/) { |match| match.upcase }
      end

      result
    end
def humanize(lower_case_and_underscored_word, options = {})
      result = lower_case_and_underscored_word.to_s.dup

      # no humans attr exists on inflections, need to port that over

      # opal - string mutation
      inflections.humans.each { |(rule, replacement)| break if (result = result.sub(rule, replacement)) }

      # opal - \A and \z not supported
      #result = result.sub(/\A_+/, ''.freeze)
      result = result.sub(/^_+/, ''.freeze)
      #result = result.sub(/_id\z/, ''.freeze)
      result = result.sub(/_id$/, ''.freeze)
      result = result.tr('_'.freeze, ' '.freeze)

      result = result.gsub(/([a-z\d]*)/i) do |match|
        "#{inflections.acronyms[match] || match.downcase}"
      end

      if options.fetch(:capitalize, true)
        #result = result.sub(/\A\w/) { |match| match.upcase }
        result = result.sub(/^\w/) { |match| match.upcase }
      end

      result
    end
Tweaks an attribute name for display to end users.

 Specifically, performs these transformations:

 * Applies human inflection rules to the argument.
 * Deletes leading underscores, if any.
 * Removes a "_id" suffix if present.
 * Replaces underscores with spaces, if any.
 * Downcases all words except acronyms.
 * Capitalizes the first word.

 The capitalization of the first word can be turned off by setting the
 +:capitalize+ option to false (default is true).

   humanize('employee_salary')              # => "Employee salary"
   humanize('author_id')                    # => "Author"
   humanize('author_id', capitalize: false) # => "author"
   humanize('_id')                          # => "Id"

 If "SSL" was defined to be an acronym:

   humanize('ssl_error') # => "SSL error"