Class: String
Instance Method Summary collapse
-
#acl_action_mapper ⇒ Object
CRUD: create, read, update, delete Read more at en.wikipedia.org/wiki/Create,_read,_update_and_delete.
- #extract_class ⇒ Object
- #extract_settings ⇒ Object
- #extract_singular_class ⇒ Object
- #remove_prefix ⇒ Object
- #to_resource ⇒ Object
Instance Method Details
#acl_action_mapper ⇒ Object
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_class ⇒ Object
11 12 13 |
# File 'lib/support/string.rb', line 11 def extract_class remove_prefix.classify.constantize end |
#extract_settings ⇒ Object
3 4 5 |
# File 'lib/support/string.rb', line 3 def extract_settings split(",").map(&:strip) end |
#extract_singular_class ⇒ Object
15 16 17 |
# File 'lib/support/string.rb', line 15 def extract_singular_class remove_prefix.camelize.constantize end |
#remove_prefix ⇒ Object
7 8 9 |
# File 'lib/support/string.rb', line 7 def remove_prefix split("/")[1..-1].join("/") end |
#to_resource ⇒ Object
36 37 38 |
# File 'lib/support/string.rb', line 36 def to_resource self.underscore.pluralize end |