module ActiveSupportDecorators
Constants
- VERSION
Public Class Methods
all(file_name, const_path = nil)
click to toggle source
# File lib/active_support_decorators/active_support_decorators.rb, line 35 def self.all(file_name, const_path = nil) file = sanitize(file_name) if const_path file = const_path.underscore else first_autoload_match = ActiveSupport::Dependencies.autoload_paths.find { |p| file.include?(p.to_s) } file.sub!(first_autoload_match, '') if first_autoload_match end relative_target = "#{file}#{pattern}.rb" expanded_paths.map { |path| File.join(path, relative_target) }.select { |candidate| File.file?(candidate) } end
debug()
click to toggle source
# File lib/active_support_decorators/active_support_decorators.rb, line 19 def self.debug @debug ||= false end
debug=(debugging_enabled)
click to toggle source
# File lib/active_support_decorators/active_support_decorators.rb, line 23 def self.debug=(debugging_enabled) @debug = debugging_enabled end
expanded_paths()
click to toggle source
# File lib/active_support_decorators/active_support_decorators.rb, line 15 def self.expanded_paths paths.map { |p| Dir[p] }.flatten end
is_decorator?(file_name)
click to toggle source
# File lib/active_support_decorators/active_support_decorators.rb, line 31 def self.is_decorator?(file_name) sanitize(file_name).ends_with?(pattern) end
log(message)
click to toggle source
# File lib/active_support_decorators/active_support_decorators.rb, line 27 def self.log(message) puts message if debug end
original_const_name(file_name)
click to toggle source
# File lib/active_support_decorators/active_support_decorators.rb, line 50 def self.original_const_name(file_name) first_match = expanded_paths.find { |path| file_name.include?(path) } if first_match sanitize(file_name).sub("#{first_match}/", '').sub(pattern, '').camelize else nil end end
paths()
click to toggle source
# File lib/active_support_decorators/active_support_decorators.rb, line 3 def self.paths @paths ||= [] end
pattern()
click to toggle source
# File lib/active_support_decorators/active_support_decorators.rb, line 7 def self.pattern @pattern ||= '_decorator' end
pattern=(pattern)
click to toggle source
# File lib/active_support_decorators/active_support_decorators.rb, line 11 def self.pattern=(pattern) @pattern = pattern end
Private Class Methods
sanitize(file_name)
click to toggle source
# File lib/active_support_decorators/active_support_decorators.rb, line 61 def self.sanitize(file_name) file_name.sub(/\.rb$/, '') end