Module: Card::Set::Type::ListedBy

Extended by:
Card::Set
Defined in:
tmpsets/set/mod021-standard/type/listed_by.rb

Overview

Set: All "ListedBy" cards

Constant Summary

Constants included from Helpers

Helpers::SET_PATTERN_TEST_REGEXP

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Card::Set

reset_modules

Methods included from I18nScope

#mod_name, #scope

Methods included from Loader

#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set

Methods included from Helpers

#method_missing, #num_set_parts, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscore

Methods included from AdvancedApi

#attachment, #ensure_set, #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 Basket

#abstract_basket, #add_to_basket, #basket, #unshift_basket

Methods included from Card::Set::Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



7
# File 'tmpsets/set/mod021-standard/type/listed_by.rb', line 7

def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/standard/set/type/listed_by.rb"; end

Instance Method Details

#add_items(items) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
# File 'tmpsets/set/mod021-standard/type/listed_by.rb', line 49

def add_items items
  items.each do |item|
    if (lc = list_card(item))
      lc.add_item name.left
      subcards.add lc
    else
      subcards.add(name: "#{Card[item].name}+#{left.type_name}",
                   type: "list",
                   content: "[[#{name.left}]]")
    end
  end
end

#contentObject



66
67
68
69
70
# File 'tmpsets/set/mod021-standard/type/listed_by.rb', line 66

def content
  content_cache.fetch(key) do
    generate_content
  end
end

#content_cacheObject



62
63
64
# File 'tmpsets/set/mod021-standard/type/listed_by.rb', line 62

def content_cache
  Card::Cache[Card::Set::Type::ListedBy]
end

#generate_contentObject



72
73
74
75
76
# File 'tmpsets/set/mod021-standard/type/listed_by.rb', line 72

def generate_content
  listed_by.map do |item|
    "[[%s]]" % item.to_name.left
  end.join "\n"
end

#list_card(item) ⇒ Object



93
94
95
# File 'tmpsets/set/mod021-standard/type/listed_by.rb', line 93

def list_card item
  Card.fetch item, left.type_name
end

#listed_byObject



78
79
80
81
82
83
# File 'tmpsets/set/mod021-standard/type/listed_by.rb', line 78

def listed_by
  Card.search(
    { type: "list", right: trunk.type_name,
      left: { type: name.tag }, refer_to: name.trunk, return: :name }, "listed_by" # better wql comment would be...better
  )
end

#old_contentObject



37
38
39
# File 'tmpsets/set/mod021-standard/type/listed_by.rb', line 37

def old_content
  db_content_before_act.present? ? db_content_before_act : content_cache.read(key)
end

#remove_items(items) ⇒ Object



41
42
43
44
45
46
47
# File 'tmpsets/set/mod021-standard/type/listed_by.rb', line 41

def remove_items items
  items.each do |item|
    next unless (lc = list_card item)
    lc.drop_item name.left
    subcards.add lc
  end
end

#unfilled?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'tmpsets/set/mod021-standard/type/listed_by.rb', line 97

def unfilled?
  false
end

#update_cached_listObject



85
86
87
88
89
90
91
# File 'tmpsets/set/mod021-standard/type/listed_by.rb', line 85

def update_cached_list
  if trunk
    Card::Cache[Card::Set::Type::ListedBy].write key, generate_content
  else
    Card::Cache[Card::Set::Type::ListedBy].delete key
  end
end