module AssociationMethods

Public Instance Methods

define_readers() click to toggle source

todo: überarbeiten

Calls superclass method
# File lib/interview/association_methods.rb, line 5
  def define_readers
    super
    mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
      def #{name}_human_ids_string
        return self.#{name}.human_ids.join(', ')
      end
    CODE
  end
define_writers() click to toggle source
Calls superclass method
# File lib/interview/association_methods.rb, line 14
  def define_writers
    super
    mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
      def #{name}_human_ids_string=(string)
        human_ids = string.split /, */
        #{name} = human_ids.map { |human_id| self.#{name}.klass.find_by_human_id(human_id) }
        self.#{name} = #{name}
      end
    CODE
  end