Skip to content
This repository was archived by the owner on Dec 28, 2019. It is now read-only.

Object transformations

Aleksander Smywiński-Pohl edited this page Mar 16, 2018 · 2 revisions

Pascalize (based on Inflecto gem, could be written from scratch)

  # Camelizes name of the given +object+ (acquired via .to_s) but with the first letter downcased.
  #
  # E.g.
  #   t(:pascalaize).(:messages_count)
  # Result:
  #   'messagesCount'
  def self.pascalaize(object)
    name = Inflecto.camelize(object)
    if name.size > 1
      name = name[0].downcase + name[1..-1]
    else
      name = name.downcase
    end
    name
  end

Clone this wiki locally