Module: RESTRack
- Defined in:
- lib/restrack/support.rb,
lib/restrack/version.rb,
lib/restrack/response.rb,
lib/restrack/generator.rb,
lib/restrack/web_service.rb,
lib/restrack/resource_request.rb,
lib/restrack/async_web_service.rb,
lib/restrack/resource_relations.rb,
lib/restrack/resource_controller.rb more...
Defined Under Namespace
Modules: ResourceRelations
Classes: AsyncWebService, Generator, ResourceController, ResourceRequest, Response, WebService
Constant Summary
collapse
- VERSION =
"1.8.2"
Class Method Summary
collapse
Class Method Details
permalink
.controller_class_for(resource_name) ⇒ Object
[View source]
41
42
43
|
# File 'lib/restrack/support.rb', line 41
def self.controller_class_for(resource_name)
Kernel.const_get( RESTRack::CONFIG[:SERVICE_NAME].to_sym ).const_get( controller_name(resource_name).to_sym )
end
|
permalink
.controller_exists?(resource_name) ⇒ Boolean
[View source]
33
34
35
36
37
38
39
|
# File 'lib/restrack/support.rb', line 33
def self.controller_exists?(resource_name)
begin
return Kernel.const_get( RESTRack::CONFIG[:SERVICE_NAME].to_sym ).const_defined?( controller_name(resource_name).to_sym )
rescue return false
end
end
|
permalink
.controller_has_action?(resource_name, action) ⇒ Boolean
[View source]
49
50
51
|
# File 'lib/restrack/support.rb', line 49
def self.controller_has_action?(resource_name, action)
controller_class_for(resource_name).const_defined?( action.to_sym )
end
|
permalink
.controller_name(resource_name) ⇒ Object
[View source]
45
46
47
|
# File 'lib/restrack/support.rb', line 45
def self.controller_name(resource_name)
"#{resource_name.to_s.camelize}Controller".to_sym
end
|
[View source]
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/restrack/support.rb', line 11
def self.load_config(file)
config = YAML.load_file(file)
@@log ||= Logger.new( config[:LOG] )
@@log.level = Logger.const_get( config[:LOG_LEVEL] )
@@request_log ||= Logger.new( config[:REQUEST_LOG] )
@@request_log.level = Logger.const_get( config[:REQUEST_LOG_LEVEL] )
if config[:ROOT_RESOURCE_ACCEPT].is_a?(Array) and config[:ROOT_RESOURCE_ACCEPT].length == 1 and config[:ROOT_RESOURCE_ACCEPT][0].lstrip.rstrip == ''
config[:ROOT_RESOURCE_ACCEPT] = nil
@@log.warn 'Improper format for RESTRack::CONFIG[:ROOT_RESOURCE_ACCEPT], should be nil or empty array not array containing empty string.'
end
if not config[:ROOT_RESOURCE_ACCEPT].blank? and not config[:DEFAULT_RESOURCE].blank? and not config[:ROOT_RESOURCE_ACCEPT].include?( config[:DEFAULT_RESOURCE] )
@@log.warn 'RESTRack::CONFIG[:DEFAULT_RESOURCE] should be a member of RESTRack::CONFIG[:ROOT_RESOURCE_ACCEPT].'
end
config
end
|
[View source]
7
|
# File 'lib/restrack/support.rb', line 7
def log; @@log; end
|
[View source]
29
30
31
|
# File 'lib/restrack/support.rb', line 29
def self.mime_type_for(format)
MIME::Types.type_for(format.to_s.downcase)[0]
end
|
[View source]
8
|
# File 'lib/restrack/support.rb', line 8
def request_log; @@request_log; end
|