Class: Object

Inherits:
BasicObject
Defined in:
lib/acts_as_lookup.rb

Overview

modify object to allow any class to act like a lookup class


Class Method Summary collapse

Class Method Details

.acts_as_lookup(options = {}) ⇒ Object

converts the calling class to act like a lookup model.

NOTE: for now, the values’ name column should not have spaces in it,

for cleanliness, though this can be addressed by gsubbing.



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/acts_as_lookup.rb', line 186

def self.acts_as_lookup(options = {})
  self.extend ActsAsLookupClassMethods

  options.merge!(:sync_with_db => true) unless options.include?(:sync_with_db)
  options.merge!(:write_to_db => true) unless options.include?(:write_to_db)
  options.merge!(:add_query_methods => false) unless options.include?(:add_query_methods)
# FUTURE:
#                           :remove_from_db => false,
#                           :shortcut_method_column => :name

  self.acts_as_lookup_options = options

  # lazy initialize? but for now explicitly initialize here
  self.acts_as_lookup_initialize
end