Class: CanTango::Config::Models

Inherits:
Object
  • Object
show all
Includes:
Helpers::Debug, ClassExt, Singleton
Defined in:
lib/cantango/config/models.rb

Instance Method Summary collapse

Instance Method Details

#actionsObject



20
21
22
# File 'lib/cantango/config/models.rb', line 20

def actions
  @actions ||= CanTango::Registry::Hash.new
end

#availableObject



46
47
48
# File 'lib/cantango/config/models.rb', line 46

def available
  all - excluded.map {|m| m.to_s.camelize}
end

#by_category(label) ⇒ Object



32
33
34
35
36
# File 'lib/cantango/config/models.rb', line 32

def by_category label
  categories[label].map do |model|
    model.class == String ? try_model(model) : model
  end
end

#by_reg_exp(reg_exp) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/cantango/config/models.rb', line 24

def by_reg_exp reg_exp
  raise "Must be a Regular Expression like: /xyz/ was #{reg_exp.inspect}" if !reg_exp.kind_of? Regexp

  grep(reg_exp).map do |model_string|
    try_model(model_string)
  end
end

#exclude(*names) ⇒ Object



38
39
40
# File 'lib/cantango/config/models.rb', line 38

def exclude *names
  @excluded = names.flatten.select_labels
end

#excludedObject



42
43
44
# File 'lib/cantango/config/models.rb', line 42

def excluded
  @excluded ||= []
end

#use(*names) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/cantango/config/models.rb', line 11

def use *names
  names = names.select_symbols
  if names.include? :guest_user
    require 'cantango/model/user/guest'
  end
rescue LoadError => e
  debug e.message
end