Sha256: e8d0540d47bdbdb7bafdd5eaa7af8f4e5b7f59af3b0ee97609eaf8405ef63f3e

Contents?: true

Size: 680 Bytes

Versions: 4

Compression:

Stored size: 680 Bytes

Contents

class String

  def extract_settings
    split(",").map { |x| x.strip }
  end

  def remove_prefix
    split("/")[1..-1].join("/")
  end

  def extract_class
    remove_prefix.classify.constantize
  end

  ##
  # CRUD: create, read, update, delete
  #
  # You can read more at http://en.wikipedia.org/wiki/Create,_read,_update_and_delete
  #
  def acl_action_mapper
    case self
    when "new", "create"
      "create"
    when "index", "show"
      "read"
    when "edit", "update", "position", "toggle", "relate", "unrelate"
      "update"
    when "destroy", "trash"
      "delete"
    else
      self
    end
  end

  def to_resource
    self.underscore.pluralize
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
typus-3.1.2 lib/support/string.rb
typus-3.1.1 lib/support/string.rb
typus-3.1.0 lib/support/string.rb
typus-3.1.0.rc19 lib/support/string.rb