Sha256: d259cc76ca6547bfff32d5ee362ad6b1c0bcb249cc65fa27989bda8c6c2cc7fa

Contents?: true

Size: 833 Bytes

Versions: 1

Compression:

Stored size: 833 Bytes

Contents

# store items as ids, not names

def standardize_item cardish
  if (id = Card.id cardish)
    "~#{id}"
  else
    Rails.logger.info "no id for '#{cardish}' added to id pointer"
    nil
  end
end

def item_ids args={}
  item_strings(args).map do |item|
    item = standardize_item item unless item.match?(/^~/)
    item.to_s.tr("~", "").to_i
  end.compact
end

def item_names args={}
  item_ids(args).map(&:cardname).compact
end

def export_content
  item_names.join "\n"
end

def replace_references _old_name, _new_name
  # noop
end

# override reference creation so there are no referee_keys
# (referee_keys can screw things up for these cards when things get renamed)
def create_references_out
  referee_ids = item_ids
  return if referee_ids.empty?

  Reference.mass_insert(referee_ids.map { |rid| [id, rid, "null", "'L'"] })
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
card-mod-list-0.15.0 set/abstract/id_list.rb