Class: String

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

Instance Method Summary collapse

Instance Method Details

#acl_action_mapperObject



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

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

#extract_classObject



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

def extract_class
  remove_prefix.classify.typus_constantize
end

#extract_settingsObject



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

def extract_settings
  split(",").map { |x| x.strip }
end

#remove_prefixObject



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

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

#to_resourceObject



34
35
36
# File 'lib/support/string.rb', line 34

def to_resource
  self.underscore.pluralize
end

#typus_constantizeObject



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

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