Sha256: 7ced85f85d032ecc411497ed2eea7619086d2fe8070f60de4ee5f939b22ee36d

Contents?: true

Size: 673 Bytes

Versions: 6

Compression:

Stored size: 673 Bytes

Contents

class String

  def extract_settings
    split(",").map(&: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

6 entries across 6 versions & 1 rubygems

Version Path
typus-3.1.8 lib/support/string.rb
typus-3.1.7 lib/support/string.rb
typus-3.1.6 lib/support/string.rb
typus-3.1.5 lib/support/string.rb
typus-3.1.4 lib/support/string.rb
typus-3.1.3 lib/support/string.rb