Class: CanTango::Configuration::Models

Inherits:
Object
  • Object
show all
Includes:
ClassExt, Singleton
Defined in:
lib/cantango/configuration/models.rb,
lib/cantango/configuration/models/mongo.rb,
lib/cantango/configuration/models/actions.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: Actions, ActiveRecord, DataMapper, Generic, Mongo, Mongoid

Instance Method Summary collapse

Instance Method Details

#actionsObject



10
11
12
# File 'lib/cantango/configuration/models.rb', line 10

def actions
  @actions ||= HashRegistry.new
end

#available_modelsObject



36
37
38
# File 'lib/cantango/configuration/models.rb', line 36

def available_models
 all_models - excluded.map {|m| m.to_s.camelize}
end

#by_category(label) ⇒ Object



22
23
24
25
26
# File 'lib/cantango/configuration/models.rb', line 22

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

#by_reg_exp(reg_exp) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/cantango/configuration/models.rb', line 14

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



28
29
30
# File 'lib/cantango/configuration/models.rb', line 28

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

#excludedObject



32
33
34
# File 'lib/cantango/configuration/models.rb', line 32

def excluded
  @excluded ||= []
end