Module: Card::Set::Abstract::IdList

Extended by:
Card::Set
Defined in:
platypus/tmp/set/gem-defaults/mod005-list/abstract/id_list.rb

Overview

store items as ids, not names

Constant Summary

Constants included from Helpers

Helpers::SET_PATTERN_TEST_REGEXP

Constants included from Event::Api

Event::Api::OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Card::Set

reset

Methods included from I18nScope

#mod_name, #scope

Methods included from Registrar

#extended, #finalize_load, #process_base_modules, #register_set

Methods included from Helpers

#format_module, #format_modules, #method_missing, #modules, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscored_name

Methods included from Card::Set::AdvancedApi

#assign_type, #attachment, #define_set_from_error, #ensure_set, #setting_opts, #stage_method

Methods included from Format

#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



8
# File 'platypus/tmp/set/gem-defaults/mod005-list/abstract/id_list.rb', line 8

def self.source_location; "/Users/ethan/dev/decko/gem/mod/list/set/abstract/id_list.rb"; end

Instance Method Details

#create_references_outObject

override reference creation so there are no referee_keys (referee_keys can screw things up for these cards when things get renamed)



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'platypus/tmp/set/gem-defaults/mod005-list/abstract/id_list.rb', line 42

def create_references_out
  referee_ids = item_ids
  return if referee_ids.empty?

  values = referee_ids.each_with_object([]) do |rid, vals|
    vals << {
      referer_id: id,
      referee_id: rid,
      referee_key: nil,
      ref_type: "L"
    }
  end

  Reference.insert_in_slices values
end

#item_ids(args = {}) ⇒ Object



19
20
21
22
23
24
25
26
# File 'platypus/tmp/set/gem-defaults/mod005-list/abstract/id_list.rb', line 19

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

#item_names(args = {}) ⇒ Object



28
29
30
# File 'platypus/tmp/set/gem-defaults/mod005-list/abstract/id_list.rb', line 28

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

#pod_contentObject



32
33
34
# File 'platypus/tmp/set/gem-defaults/mod005-list/abstract/id_list.rb', line 32

def pod_content
  item_names.join "\n"
end

#replace_references(_old_name, _new_name) ⇒ Object



36
37
38
# File 'platypus/tmp/set/gem-defaults/mod005-list/abstract/id_list.rb', line 36

def replace_references _old_name, _new_name
  # noop
end

#standardize_item(cardish) ⇒ Object



10
11
12
13
14
15
16
17
# File 'platypus/tmp/set/gem-defaults/mod005-list/abstract/id_list.rb', line 10

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