reader_method(name, class_name, mapping, allow_nil) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/aggregations.rb, line 151
        def reader_method(name, class_name, mapping, allow_nil)
          module_eval do
            define_method(name) do |*args|
              force_reload = args.first || false
              if (instance_variable_get("@#{name}").nil? || force_reload) && (!allow_nil || mapping.any? {|pair| !read_attribute(pair.first).nil? })
                instance_variable_set("@#{name}", class_name.constantize.new(*mapping.collect {|pair| read_attribute(pair.first)}))
              end
              return instance_variable_get("@#{name}")
            end
          end

        end
Register or log in to add new notes.