module ContextService
Private Instance Methods
action_context()
click to toggle source
# File lib/context_service.rb, line 16 def action_context convert_name(params[:action]) end
context_service()
click to toggle source
# File lib/context_service.rb, line 4 def context_service Object.const_get "#{service_module}::#{controller_context}::#{action_context}" end
controller_context()
click to toggle source
# File lib/context_service.rb, line 12 def controller_context convert_name(params[:controller]) end
convert_name(name)
click to toggle source
# File lib/context_service.rb, line 20 def convert_name(name) name = name.to_s.sub(/^[a-z\d]*/) { $&.capitalize } name.gsub(%r{(?:_|(/))([a-z\d]*)}) { "#{Regexp.last_match(1)}#{Regexp.last_match(2).capitalize}" }.gsub('/', '::') end
service_module()
click to toggle source
# File lib/context_service.rb, line 8 def service_module '' end