Sha256: 2ac22ae01f01ce5524d37a6d2c6a8d7b0f80cccd2231512e5886f418e5ee3a1c

Contents?: true

Size: 785 Bytes

Versions: 3

Compression:

Stored size: 785 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.typus_constantize
  end

  def typus_constantize
    Typus::Configuration.models_constantized[self]
  end

  def action_mapper
    case self
    when "index" then :list
    when "new", "create", "edit", "update" then :form
    else self
    end
  end

  def acl_action_mapper
    case self
    when "new", "create"
      "create"
    when "index", "show"
      "read"
    when "edit", "update", "position", "toggle", "relate", "unrelate", "detach"
      "update"
    when "destroy", "trash"
      "delete"
    else
      self
    end
  end

  def to_resource
    self.underscore.pluralize
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
typus-3.0.6 lib/support/string.rb
typus-3.0.5 lib/support/string.rb
typus-3.0.4 lib/support/string.rb