module Decorators

Public Class Methods

decorators() click to toggle source
# File lib/decorators.rb, line 18
def decorators
  paths.registered.map(&method(:find_decorators_in_path)).flatten.uniq
end
load!(cache_classes) click to toggle source
# File lib/decorators.rb, line 5
def load!(cache_classes)
  decorators_with_argument_errors = []
  decorators.each do |decorator|
    load_decorator(decorator, cache_classes)
  rescue ArgumentError
    decorators_with_argument_errors << decorator
  end

  decorators_with_argument_errors.each do |decorator|
    load_decorator(decorator, cache_classes)
  end
end
register!(*paths_to_register) click to toggle source
# File lib/decorators.rb, line 22
def register!(*paths_to_register)
  paths_to_register.flatten.map do |path|
    paths.register! path
  end
end

Private Class Methods

apply_decorators_pattern_to_path(path) click to toggle source
# File lib/decorators.rb, line 34
def apply_decorators_pattern_to_path(path)
  path.join(*pattern)
end
find_decorators_in_path(path) click to toggle source
# File lib/decorators.rb, line 38
def find_decorators_in_path(path)
  Dir[apply_decorators_pattern_to_path(path)]
end
load_decorator(decorator, cache_classes) click to toggle source
# File lib/decorators.rb, line 42
def load_decorator(decorator, cache_classes)
  if cache_classes
    require decorator
  else
    load decorator
  end
end
paths() click to toggle source
# File lib/decorators.rb, line 30
def paths
  @paths ||= Paths.new
end
pattern() click to toggle source
# File lib/decorators.rb, line 50
def pattern
  ["app", "decorators", "*", "**", "*_decorator.rb"]
end