Module: Card::Set::All::Subcards

Extended by:
Card::Set
Defined in:
tmpsets/set/mod003-core/all/subcards.rb

Overview

Set: All cards (Subcards)

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 Card::Set::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 Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



7
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 7

def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/core/set/all/subcards.rb"; end

Instance Method Details

#attach_subcard(name_or_card, args = {}) ⇒ Object Also known as: add_subcard

phase_method :attach_subcard, before: :store do |name_or_card, args=nil| TODO: handle differently in different stages



43
44
45
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 43

def attach_subcard name_or_card, args={}
  subcards.add name_or_card, args
end

#attach_subcard!(name_or_card, args = {}) ⇒ Object



48
49
50
51
52
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 48

def attach_subcard! name_or_card, args={}
  subcard = subcards.add name_or_card, args
  subcard.director.reset_stage
  subcard
end

#attach_subfield(name_or_card, args = {}) ⇒ Object Also known as: add_subfield

phase_method :attach_subfield, before: :approve do |name_or_card, args=nil|



55
56
57
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 55

def attach_subfield name_or_card, args={}
  subcards.add_field name_or_card, args
end

#attach_subfield!(name_or_card, args = {}) ⇒ Object



60
61
62
63
64
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 60

def attach_subfield! name_or_card, args={}
  subcard = subcards.add_field name_or_card, args
  subcard.director.reset_stage
  subcard
end

#clear_subcardsObject



76
77
78
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 76

def clear_subcards
  subcards.clear
end

#deep_clear_subcardsObject



84
85
86
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 84

def deep_clear_subcards
  subcards.deep_clear
end

#detach_subcard(name_or_card) ⇒ Object Also known as: remove_subcard



66
67
68
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 66

def detach_subcard name_or_card
  subcards.remove name_or_card
end

#detach_subfield(name_or_card) ⇒ Object Also known as: remove_subfield



71
72
73
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 71

def detach_subfield name_or_card
  subcards.remove_field name_or_card
end

#expire_subcardsObject



32
33
34
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 32

def expire_subcards
  subcards.clear
end

#field(tag, opts = {}) ⇒ Object



8
9
10
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 8

def field tag, opts={}
  Card.fetch name.field(tag), opts
end

#field?(tag) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 20

def field? tag
  field(tag) || subfield(tag)
end

#save_as_subcard!Object



36
37
38
39
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 36

def save_as_subcard!
  self.only_storage_phase = true
  save! validate: false
end

#subcard(card_name) ⇒ Object



12
13
14
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 12

def subcard card_name
  subcards.card card_name
end

#subcard_error(subcard, field, err) ⇒ Object



97
98
99
100
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 97

def subcard_error subcard, field, err
  err = "#{field} #{err}" unless %i[content abort].member? field
  errors.add subcard.name.from(name), err
end

#subcardsObject



24
25
26
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 24

def subcards
  @subcards ||= Card::Subcards.new self
end

#subcards?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 28

def subcards?
  subcards.present?
end

#subfield(field_name) ⇒ Object



16
17
18
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 16

def subfield field_name
  subcards.field field_name
end

#subfield_present?(field_name) ⇒ Boolean

Returns:

  • (Boolean)


80
81
82
# File 'tmpsets/set/mod003-core/all/subcards.rb', line 80

def subfield_present? field_name
  (field_card = subfield(field_name)) && field_card.content.present?
end