Sha256: 7f5f060e7cb1841a65d7335395c86f0f2a642bc883e528fd9c22472bdd4706f8

Contents?: true

Size: 801 Bytes

Versions: 2

Compression:

Stored size: 801 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", "toggle" then :form
    else self
    end
  end

  def acl_action_mapper
    case self
    when "new", "create"
      "create"
    when "index", "show", "autocomplete"
      "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

2 entries across 2 versions & 1 rubygems

Version Path
typus-3.0.8 lib/support/string.rb
typus-3.0.7 lib/support/string.rb