Class: CanTango::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/cantango/configuration.rb,
lib/cantango/configuration/user.rb,
lib/cantango/configuration/debug.rb,
lib/cantango/configuration/guest.rb,
lib/cantango/configuration/modes.rb,
lib/cantango/configuration/roles.rb,
lib/cantango/configuration/users.rb,
lib/cantango/configuration/models.rb,
lib/cantango/configuration/ability.rb,
lib/cantango/configuration/engines.rb,
lib/cantango/configuration/factory.rb,
lib/cantango/configuration/permits.rb,
lib/cantango/configuration/adapters.rb,
lib/cantango/configuration/autoload.rb,
lib/cantango/configuration/registry.rb,
lib/cantango/configuration/categories.rb,
lib/cantango/configuration/role_groups.rb,
lib/cantango/configuration/models/mongo.rb,
lib/cantango/configuration/user_account.rb,
lib/cantango/configuration/engines/cache.rb,
lib/cantango/configuration/engines/store.rb,
lib/cantango/configuration/hash_registry.rb,
lib/cantango/configuration/role_registry.rb,
lib/cantango/configuration/user_accounts.rb,
lib/cantango/configuration/engines/engine.rb,
lib/cantango/configuration/engines/permit.rb,
lib/cantango/configuration/models/actions.rb,
lib/cantango/configuration/models/generic.rb,
lib/cantango/configuration/models/mongoid.rb,
lib/cantango/configuration/engines/user_ac.rb,
lib/cantango/configuration/permit_registry.rb,
lib/cantango/configuration/candidate_registry.rb,
lib/cantango/configuration/engines/permission.rb,
lib/cantango/configuration/models/data_mapper.rb,
lib/cantango/configuration/models/active_record.rb

Defined Under Namespace

Modules: Factory, Modes Classes: Ability, Adapters, Autoload, CandidateRegistry, Categories, Debug, Engines, Guest, HashRegistry, Models, PermitRegistry, Permits, Registry, RoleGroups, RoleRegistry, Roles, User, UserAccount, UserAccounts, Users

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#localhost_listObject



86
87
88
# File 'lib/cantango/configuration.rb', line 86

def localhost_list
  @localhost_list ||= ['localhost', '0.0.0.0', '127.0.0.1']
end

#ormsObject

Returns the value of attribute orms.



83
84
85
# File 'lib/cantango/configuration.rb', line 83

def orms
  @orms
end

Class Method Details

.componentsObject



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

def self.components
  [
    :guest, :autoload, :user, :user_account, :models, :roles, :role_groups,
    :engines, :users, :user_accounts, :categories, :adapters, :permits, :debug
  ]
end

Instance Method Details

#abilityObject



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

def ability
  @ability ||= conf::Ability.instance
  @ability.default_class ||= CanTango::AbilityExecutor
  @ability
end

#clear!Object



58
59
60
61
62
63
64
# File 'lib/cantango/configuration.rb', line 58

def clear!
  CanTango::Configuration.components.each do |c|
    comp = send(c)
    comp.send(:clear!) if comp.respond_to? :clear!
  end
  engines.clear!
end

#debug!Object



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

def debug!
  debug.set :on
end

#enable_defaults!Object

Turn on all engines and enable compile adapter i.e compilation of rules via sourcify



44
45
46
47
# File 'lib/cantango/configuration.rb', line 44

def enable_defaults!
  engines.all :on
  adapters.use :compiler
end

#enable_helpers(*names) ⇒ Object



49
50
51
52
# File 'lib/cantango/configuration.rb', line 49

def enable_helpers *names
  names = names.to_symbols
  enable_rest_helper if names.include? :rest
end

#enable_rest_helperObject



54
55
56
# File 'lib/cantango/configuration.rb', line 54

def enable_rest_helper
  ApplicationController.send :include, CanTango::Rails::Helpers::RestHelper
end

#engine(name) {|engine| ... } ⇒ Object

allow either block or direct access engine(:permission) do |permission| engine(:permission).config_path

Yields:



77
78
79
80
81
# File 'lib/cantango/configuration.rb', line 77

def engine name, &block
  engine = find_engine(name)
  yield engine if block
  engine
end