lib/canard/find_abilities.rb in canard-0.2.7 vs lib/canard/find_abilities.rb in canard-0.3.1
- old
+ new
@@ -2,12 +2,16 @@
class << self
# A string specifying the location that should be searched for ability
# definitions. By default, Canard will attempt to load abilities from
# Rails.root + /abilities/.
- attr_accessor :abilities_path
+ attr_writer :abilities_path
+ def abilities_path
+ @abilities_path ||= File.expand_path('abilities', Rails.root)
+ end
+
def ability_definitions
Abilities.definitions
end
def abilities_for(role, &block)
@@ -16,10 +20,9 @@
end
end
def self.find_abilities #:nodoc:
-
absolute_abilities_path = File.expand_path(abilities_path)
if File.directory? absolute_abilities_path
Dir[File.join(absolute_abilities_path, '**', '*.rb')].sort.each do |file|
self.class_eval File.read(file)
\ No newline at end of file