Class: CanTango::Configuration::Models
- Inherits:
-
Object
- Object
- CanTango::Configuration::Models
show all
- Includes:
- ClassExt, Singleton
- Defined in:
- lib/cantango/configuration/models.rb,
lib/cantango/configuration/models/mongo.rb,
lib/cantango/configuration/models/generic.rb,
lib/cantango/configuration/models/mongoid.rb,
lib/cantango/configuration/models/data_mapper.rb,
lib/cantango/configuration/models/active_record.rb
Defined Under Namespace
Classes: ActiveRecord, DataMapper, Generic, Mongo, Mongoid
Instance Method Summary
collapse
Instance Method Details
#available_models ⇒ Object
31
32
33
|
# File 'lib/cantango/configuration/models.rb', line 31
def available_models
all_models - excluded.map {|m| m.to_s.camelize}
end
|
#by_category(label) ⇒ Object
17
18
19
20
21
|
# File 'lib/cantango/configuration/models.rb', line 17
def by_category label
categories[label].map do |model|
model.class == String ? try_model(model) : model
end
end
|
#by_reg_exp(reg_exp) ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/cantango/configuration/models.rb', line 9
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
23
24
25
|
# File 'lib/cantango/configuration/models.rb', line 23
def exclude *names
@excluded = names.flatten.select_labels
end
|
#excluded ⇒ Object
27
28
29
|
# File 'lib/cantango/configuration/models.rb', line 27
def excluded
@excluded ||= []
end
|