Sha256: 6bb192f61d4721561b2d3e3ab052cbaf51c21d5a0a2c8c88ed135390639b69af

Contents?: true

Size: 727 Bytes

Versions: 15

Compression:

Stored size: 727 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

  def extract_singular_class
    remove_prefix.camelize.constantize
  end

  # CRUD: create, read, update, delete
  # 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

15 entries across 15 versions & 2 rubygems

Version Path
brainsome_typus-4.0.0.beta13 lib/support/string.rb
brainsome_typus-4.0.0.beta12 lib/support/string.rb
brainsome_typus-4.0.0.beta11 lib/support/string.rb
brainsome_typus-4.0.0.beta10 lib/support/string.rb
brainsome_typus-4.0.0.beta9 lib/support/string.rb
brainsome_typus-4.0.0.beta8 lib/support/string.rb
brainsome_typus-4.0.0.beta7 lib/support/string.rb
brainsome_typus-4.0.0.beta6 lib/support/string.rb
brainsome_typus-4.0.0.beta5 lib/support/string.rb
brainsome_typus-4.0.0.beta4 lib/support/string.rb
brainsome_typus-4.0.0.beta3 lib/support/string.rb
brainsome_typus-4.0.0.beta2 lib/support/string.rb
brainsome_typus-4.0.0.beta1 lib/support/string.rb
typus-3.1.10 lib/support/string.rb
typus-3.1.9 lib/support/string.rb