Module: Card::Set::Abstract::CodePointer::ClassMethods

Defined in:
tmpsets/set/mod008-pointer/abstract/code_pointer.rb

Overview

simplify api Self::MyCodePointerSet.add_item :my_item_codename instead of Self::MyCodePointerSet.add_to_basket :item_codenames, :my_item_codename

Instance Method Summary collapse

Instance Method Details

#add_item(codename) ⇒ Object



17
18
19
20
21
# File 'tmpsets/set/mod008-pointer/abstract/code_pointer.rb', line 17

def add_item codename
  valid_codename codename do
    add_to_basket :item_codenames, codename
  end
end

#unshift_item(codename) ⇒ Object



23
24
25
26
27
# File 'tmpsets/set/mod008-pointer/abstract/code_pointer.rb', line 23

def unshift_item codename
  valid_codename codename do
    unshift_basket :item_codenames, codename
  end
end

#valid_codename(codename) ⇒ Object



29
30
31
32
33
34
35
# File 'tmpsets/set/mod008-pointer/abstract/code_pointer.rb', line 29

def valid_codename codename
  if Card::Codename.exist? codename
    yield
  else
    Rails.logger.info "unknown codename '#{codename}' added to code pointer"
  end
end