Module: EnumeratedAttribute::Integrations

Defined in:
lib/enumerated_attribute/integrations.rb,
lib/enumerated_attribute/integrations/object.rb,
lib/enumerated_attribute/integrations/default.rb,
lib/enumerated_attribute/integrations/active_record.rb

Defined Under Namespace

Modules: ActiveRecord, Default, Object

Constant Summary collapse

@@integration_map =
{}

Class Method Summary collapse

Class Method Details

.add_integration_map(base_klass_name, module_object, aliasing_array = []) ⇒ Object Also known as: add



11
12
13
# File 'lib/enumerated_attribute/integrations.rb', line 11

def self.add_integration_map(base_klass_name, module_object, aliasing_array=[])
	@@integration_map[base_klass_name] = {:module=>module_object, :aliasing=>aliasing_array}
end

.find_integration_map(klass) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/enumerated_attribute/integrations.rb', line 22

def self.find_integration_map(klass)
	path = "#{klass}"
	begin
		return @@integration_map[klass.to_s] if @@integration_map.key?(klass.to_s)
		klass = klass.superclass
		path << " < #{klass}"
	end while klass
	raise EnumeratedAttribute::IntegrationError, "Unable to find integration for class hierarchy '#{path}'", caller
end