module ConstantTableSaver::NameClassMethods
Public Instance Methods
define_named_record_methods()
click to toggle source
# File lib/constant_table_saver.rb, line 202 def define_named_record_methods @constant_record_methods = [] # dummy so respond_to? & method_missing don't call us again if reading an attribute causes another method_missing @constant_record_methods = all.collect do |record| method_name = "#{constant_table_options[:name_prefix]}#{record[constant_table_options[:name]].downcase.gsub(/\W+/, '_')}#{constant_table_options[:name_suffix]}" next if method_name.blank? (class << self; self; end;).instance_eval { define_method(method_name) { record } } method_name.to_sym end.compact.uniq end
method_missing(method_id, *arguments, &block)
click to toggle source
Calls superclass method
# File lib/constant_table_saver.rb, line 216 def method_missing(method_id, *arguments, &block) if @constant_record_methods.nil? define_named_record_methods send(method_id, *arguments, &block) # retry else super end end
respond_to?(method_id, include_private = false)
click to toggle source
Calls superclass method
# File lib/constant_table_saver.rb, line 212 def respond_to?(method_id, include_private = false) super || (@constant_record_methods.nil? && @attribute_methods_generated && define_named_record_methods && super) end