Module: Canard

Defined in:
lib/canard/railtie.rb,
lib/canard/version.rb,
lib/canard/abilities.rb,
lib/canard/user_model.rb,
lib/canard/find_abilities.rb,
lib/canard/adapters/active_record.rb,
lib/generators/canard/ability/ability_generator.rb

Defined Under Namespace

Modules: Adapters, Generators, UserModel Classes: Abilities, Railtie

Constant Summary collapse

VERSION =
"0.3.6"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.abilities_pathObject



9
10
11
# File 'lib/canard/find_abilities.rb', line 9

def abilities_path 
  @abilities_path ||= 'abilities'
end

Class Method Details

.abilities_for(role, &block) ⇒ Object



17
18
19
20
# File 'lib/canard/find_abilities.rb', line 17

def abilities_for(role, &block)
  ::ActiveSupport::Deprecation.warn("abilities_for is deprecated and will be removed from Canard 0.4.0. Use Canard::Abilities.for and move the definitions to app/abilities.")
  ability_definitions[role] = block
end

.ability_definitionsObject



13
14
15
# File 'lib/canard/find_abilities.rb', line 13

def ability_definitions
  Abilities.definitions
end

.find_abilitiesObject

TODO remove at version 0.4.0



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/canard/find_abilities.rb', line 29

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)
    end
  end
  
  load_paths.each do |path|
    Dir[File.join(path, '**', '*.rb')].sort.each do |file|
      load file
    end
  end

end

.load_pathsObject



24
25
26
# File 'lib/canard/find_abilities.rb', line 24

def self.load_paths
  Abilities.definition_paths.map { |path| File.expand_path(path) }
end