Module: CanTango::Registry::Permit

Included in:
Config::Permits, Base
Defined in:
lib/cantango/permits_ext/registry/permit.rb

Defined Under Namespace

Classes: Base

Instance Method Summary collapse

Instance Method Details

#allObject



15
16
17
# File 'lib/cantango/permits_ext/registry/permit.rb', line 15

def all
  (available_types - [:special]).map{|type| registry_for(type) }
end

#registered_for(type, name = nil) ⇒ Object



11
12
13
# File 'lib/cantango/permits_ext/registry/permit.rb', line 11

def registered_for type, name = nil
  name ? registry_for(type)[name.to_s] : registry_for(type)
end

#registry_for(type) ⇒ Object

Raises:

  • (ArgumentError)


4
5
6
7
8
9
# File 'lib/cantango/permits_ext/registry/permit.rb', line 4

def registry_for type
  raise ArgumentError, "Not an available permit type, was: #{type} - available: #{available_types}" unless available_type? type
  inst_var_name = "@#{type}"
  instance_variable_set(inst_var_name, CanTango::Registry::Hash.new) if !instance_variable_get(inst_var_name)
  instance_variable_get(inst_var_name)
end

#show_allObject



19
20
21
# File 'lib/cantango/permits_ext/registry/permit.rb', line 19

def show_all
  (available_types - [:special]).map{|type| "#{type} -> #{show_hash_reg(registry_for(type))}"  }.join("\n")
end