Class: String

Inherits:
Object show all
Defined in:
lib/support/string.rb

Instance Method Summary collapse

Instance Method Details

#acl_action_mapperObject

CRUD: create, read, update, delete Read more at en.wikipedia.org/wiki/Create,_read,_update_and_delete



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/support/string.rb', line 21

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

#extract_classObject



11
12
13
# File 'lib/support/string.rb', line 11

def extract_class
  remove_prefix.classify.constantize
end

#extract_settingsObject



3
4
5
# File 'lib/support/string.rb', line 3

def extract_settings
  split(",").map(&:strip)
end

#extract_singular_classObject



15
16
17
# File 'lib/support/string.rb', line 15

def extract_singular_class
  remove_prefix.camelize.constantize
end

#remove_prefixObject



7
8
9
# File 'lib/support/string.rb', line 7

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

#to_resourceObject



36
37
38
# File 'lib/support/string.rb', line 36

def to_resource
  self.underscore.pluralize
end