Module: Card::Set::All::ItemAssignment
- Extended by:
- Card::Set
- Defined in:
- platypus/tmp/set/gem-defaults/mod002-collection/all/item_assignment.rb
Overview
set card content based on array and save card
Constant Summary
Constants included from Helpers
Helpers::SET_PATTERN_TEST_REGEXP
Constants included from Event::Api
Class Method Summary collapse
Instance Method Summary collapse
-
#<<(cardish) ⇒ Object
append item to list (does not save).
-
#add_item(cardish, allow_duplicates = false) ⇒ Object
append item to list (does not save).
-
#add_item!(name) ⇒ Object
append item to list and save card.
-
#drop_item(cardish) ⇒ Object
remove item from list.
-
#drop_item!(cardish) ⇒ Object
remove item from list and save card.
-
#insert_item(index, name) ⇒ Object
insert item into list at specified location.
-
#insert_item!(index, name) ⇒ Object
insert item into list at specified location and save.
-
#items=(array) ⇒ Object
-
#items_content(array) ⇒ Object
-
#replace_item(old, new) ⇒ Object
-
#standardize_item(item) ⇒ Object
-
#standardized_items(array) ⇒ Object
Methods included from Card::Set
Methods included from I18nScope
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
Class Method Details
.source_location ⇒ Object
8 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item_assignment.rb', line 8 def self.source_location; "/Users/ethan/dev/decko/gem/mod/collection/set/all/item_assignment.rb"; end |
Instance Method Details
#<<(cardish) ⇒ Object
append item to list (does not save)
17 18 19 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item_assignment.rb', line 17 def << cardish add_item cardish end |
#add_item(cardish, allow_duplicates = false) ⇒ Object
append item to list (does not save)
24 25 26 27 28 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item_assignment.rb', line 24 def add_item cardish, allow_duplicates=false return if !allow_duplicates && include_item?(cardish) self.content = (item_strings << cardish) end |
#add_item!(name) ⇒ Object
append item to list and save card
32 33 34 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item_assignment.rb', line 32 def add_item! name add_item(name) && save! end |
#drop_item(cardish) ⇒ Object
remove item from list
38 39 40 41 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item_assignment.rb', line 38 def drop_item cardish item_name = cardish.cardname self.content = (item_names.reject { |i| i == item_name }) end |
#drop_item!(cardish) ⇒ Object
remove item from list and save card
45 46 47 48 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item_assignment.rb', line 45 def drop_item! cardish drop_item cardish save! end |
#insert_item(index, name) ⇒ Object
insert item into list at specified location
53 54 55 56 57 58 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item_assignment.rb', line 53 def insert_item index, name new_names = item_names new_names.delete name new_names.insert index, name self.content = new_names end |
#insert_item!(index, name) ⇒ Object
insert item into list at specified location and save
63 64 65 66 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item_assignment.rb', line 63 def insert_item! index, name insert_item index, name save! end |
#items=(array) ⇒ Object
10 11 12 13 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item_assignment.rb', line 10 def items= array self.content = array save! end |
#items_content(array) ⇒ Object
75 76 77 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item_assignment.rb', line 75 def items_content array standardized_items(array).to_pointer_content end |
#replace_item(old, new) ⇒ Object
68 69 70 71 72 73 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item_assignment.rb', line 68 def replace_item old, new return unless include_item? old drop_item old add_item new end |
#standardize_item(item) ⇒ Object
83 84 85 86 87 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item_assignment.rb', line 83 def standardize_item item Card::Name[item] rescue Card::Error::NotFound item end |
#standardized_items(array) ⇒ Object
79 80 81 |
# File 'platypus/tmp/set/gem-defaults/mod002-collection/all/item_assignment.rb', line 79 def standardized_items array array.map { |i| standardize_item i }.reject(&:blank?) end |