Module: AssociationMethods

Included in:
ActiveRecord::Associations::Builder::CollectionAssociation
Defined in:
lib/interview/association_methods.rb

Instance Method Summary collapse

Instance Method Details

#define_readersObject



3
4
5
6
7
8
9
10
# File 'lib/interview/association_methods.rb', line 3

def define_readers
  super
  mixin.class_eval "    def \#{name}_human_ids_string\n      return self.\#{name}.human_ids.join(', ')\n    end\n  CODE\nend\n", __FILE__, __LINE__ + 1

#define_writersObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/interview/association_methods.rb', line 12

def define_writers
  super
  mixin.class_eval "    def \#{name}_human_ids_string=(string)\n      human_ids = string.split /, */\n      \#{name} = human_ids.map { |human_id| self.\#{name}.klass.find_by_human_id(human_id) }\n      self.\#{name} = \#{name}\n    end\n  CODE\nend\n", __FILE__, __LINE__ + 1