Sha256: cd22aac3fa966d4c14e79bdc916aa9c8a73212649c0af3f8fb0cfb1b5c641478

Contents?: true

Size: 1.03 KB

Versions: 14

Compression:

Stored size: 1.03 KB

Contents

require 'enumerated_attribute/integrations/active_record'
require 'enumerated_attribute/integrations/object'
require 'enumerated_attribute/integrations/datamapper'
require 'enumerated_attribute/integrations/default'

module EnumeratedAttribute
	module Integrations

		@@integration_map = {}
		
		def self.add_integration_map(base_klass_name, module_object, aliasing_array=[])
			@@integration_map[base_klass_name] = {:module=>module_object, :aliasing=>aliasing_array}
		end
		class << self
			alias_method(:add, :add_integration_map)
		end
		
		#included mappings
		add('Object', EnumeratedAttribute::Integrations::Object)
		add('ActiveRecord::Base', EnumeratedAttribute::Integrations::ActiveRecord)
		
		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
	
	end
end

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
jeffp-enumerated_attribute-0.1.6 lib/enumerated_attribute/integrations.rb
jeffp-enumerated_attribute-0.1.7 lib/enumerated_attribute/integrations.rb
jeffp-enumerated_attribute-0.2.0.2 lib/enumerated_attribute/integrations.rb
jeffp-enumerated_attribute-0.2.1 lib/enumerated_attribute/integrations.rb
jeffp-enumerated_attribute-0.2.2 lib/enumerated_attribute/integrations.rb
jeffp-enumerated_attribute-0.2.3 lib/enumerated_attribute/integrations.rb
edave-enumerated_attribute-0.2.18 lib/enumerated_attribute/integrations.rb
enumerated_attribute-0.2.16 lib/enumerated_attribute/integrations.rb
enumerated_attribute-0.2.13 lib/enumerated_attribute/integrations.rb
enumerated_attribute-0.2.12 lib/enumerated_attribute/integrations.rb
enumerated_attribute-0.2.11 lib/enumerated_attribute/integrations.rb
enumerated_attribute-0.2.10 lib/enumerated_attribute/integrations.rb
enumerated_attribute-0.2.8 lib/enumerated_attribute/integrations.rb
enumerated_attribute-0.2.7 lib/enumerated_attribute/integrations.rb