Module: Scribbler::Includeables::ClassMethods
- Defined in:
- lib/scribbler/includeables.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
Public: defines methods for log location. The first element defines the prefix for the method so “subseason” = subseason_log_location. The second element defines the name of the logfile so “subseason” = root_of_app/log/subseason.log
Examples
subseason_log_location
Returns Pathname to log
33
34
35
|
# File 'lib/scribbler/includeables.rb', line 33
def method_missing(name, *args, &block)
(match = name.to_s.match log_location_regex) ? log_at(match[:file]) : super
end
|
Instance Method Details
#log(*args) ⇒ Object
10
11
12
|
# File 'lib/scribbler/includeables.rb', line 10
def log(*args)
logger.log *args
end
|
#log_at(location) ⇒ Object
14
15
16
|
# File 'lib/scribbler/includeables.rb', line 14
def log_at(location)
LogLocation.new.find_path location
end
|
#log_location_regex ⇒ Object
18
19
20
|
# File 'lib/scribbler/includeables.rb', line 18
def log_location_regex
/(?<file>.*)_log_location$/
end
|
#logger ⇒ Object
6
7
8
|
# File 'lib/scribbler/includeables.rb', line 6
def logger
Logger
end
|
#respond_to?(name) ⇒ Boolean
37
38
39
|
# File 'lib/scribbler/includeables.rb', line 37
def respond_to?(name)
(m = name.to_s.match log_location_regex) ? !!m : super
end
|