Class: CanTango::Configuration::PermitRegistry
- Inherits:
-
Object
- Object
- CanTango::Configuration::PermitRegistry
- Defined in:
- lib/cantango/configuration/permit_registry.rb
Direct Known Subclasses
Instance Method Summary collapse
- #all ⇒ Object
- #available_types ⇒ Object
- #permits_for(type) ⇒ Object
- #registered_by(type) ⇒ Object
- #registered_for(type, name = nil) ⇒ Object
- #show_all ⇒ Object
Instance Method Details
#all ⇒ Object
19 20 21 |
# File 'lib/cantango/configuration/permit_registry.rb', line 19 def all (available_types - [:special]).map{|type| permits_for(type)} end |
#available_types ⇒ Object
27 28 29 |
# File 'lib/cantango/configuration/permit_registry.rb', line 27 def available_types CanTango.config.permits.available_types end |
#permits_for(type) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/cantango/configuration/permit_registry.rb', line 4 def permits_for type raise ArgumentError, "Not an available permit type: #{type}, available are: #{available_types}" if !available_types.include? type inst_var_name = "@#{type}" instance_variable_set(inst_var_name, HashRegistry.new) if !instance_variable_get(inst_var_name) instance_variable_get(inst_var_name) end |
#registered_by(type) ⇒ Object
15 16 17 |
# File 'lib/cantango/configuration/permit_registry.rb', line 15 def registered_by type permits_for(type).registered end |
#registered_for(type, name = nil) ⇒ Object
11 12 13 |
# File 'lib/cantango/configuration/permit_registry.rb', line 11 def registered_for type, name = nil name ? registered_by(type)[name.to_s] : registered_by(type) end |
#show_all ⇒ Object
23 24 25 |
# File 'lib/cantango/configuration/permit_registry.rb', line 23 def show_all all.map(&:registered) end |