lib/config_scripts/seeds/seed_type.rb
# This method gets the value that we should write into the CSV file for
# an attribute.
#
# If the value for that attribute is another model record, this will get
# its seed identifier from the seed set. Otherwise, it will just use the
# value.
#
# If the attribute is a polymorphic foreign key, this will prefix the seed
# identifier with the class name.
#
# @param [ActiveRecord::Base] item
#   The record whose value we are getting.
#
# @param [Symbol] attribute
#   The attribute we are getting.
#
# @return [String]
#   The value to write.
This method gets the value that we should write into the CSV file for
an attribute.

If the value for that attribute is another model record, this will get
its seed identifier from the seed set. Otherwise, it will just use the
value.

If the attribute is a polymorphic foreign key, this will prefix the seed
identifier with the class name.
This method gets the value that we should write into the CSV file for an attribute . If the value for that attribute is another model record this will get its seed identifier from the seed set . Otherwise it will just use the value . If the attribute is a polymorphic foreign key this will prefix the seed identifier with the class name .
def write_value_for_attribute(item, attribute)
        if @dynamic_writers[attribute]
          value = @dynamic_writers[attribute].call(item)
        else
          value = item.send(attribute)
        end
        if value.is_a?(ActiveRecord::Base)
          identifier = self.seed_set.seed_identifier_for_record(value)
          if !self.associations[attribute]
            identifier = "#{value.class.name}::#{identifier}"
          end
          value = identifier
        end
        value
      end
def write_value_for_attribute ( item , attribute ) if @dynamic_writers [ attribute ] value = @dynamic_writers [ attribute ] . call ( item ) else value = item . send ( attribute ) end if value . is_a? ( ActiveRecord :: Base ) identifier = self . seed_set . seed_identifier_for_record ( value ) if ! self . associations [ attribute ] identifier = "#{value.class.name}::#{identifier}" end value = identifier end value end
This method gets the value that we should write into the CSV file for
an attribute.
This method gets the value that we should write into the CSV file for an attribute .
The value to write.
The value to write .
String
item
<not_specific>
attribute
<not_specific>
<not_specific>
attribute The attribute we are getting.
attribute The attribute we are getting .