Module: Card::Set::All::Type

Extended by:
Card::Set
Defined in:
platypus/tmp/set/gem-card/mod001-core/all/type.rb

Overview

Set: All cards (Type)

Defined Under Namespace

Modules: ClassMethods

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



7
# File 'platypus/tmp/set/gem-card/mod001-core/all/type.rb', line 7

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

Instance Method Details

#event: validate_typeObject



23
24
25
26
27
28
29
30
# File 'platypus/tmp/set/gem-card/mod001-core/all/type.rb', line 23

event :validate_type, :validate, changed: :type_id, on: :save do
  errors.add :type, t(:core_error_no_such_type) unless type_name

  if structure&.assigns_type? && type_id != structure.type_id
    errors.add :type,
               t(:core_error_hard_templated, name: name, type_name: structure.type_name)
  end
end

#event: validate_type_changeObject



14
15
16
17
18
19
20
21
# File 'platypus/tmp/set/gem-card/mod001-core/all/type.rb', line 14

event :validate_type_change, :validate, on: :update, changed: :type_id do
  return unless (c = dup) && (c.action == :create) && !c.valid?

  errors.add :type, t(:core_error_cant_change_errors,
                      name: name,
                      type_id: type_id,
                      error_messages: c.errors.full_messages)
end

#type=(type_name) ⇒ Object



54
55
56
# File 'platypus/tmp/set/gem-card/mod001-core/all/type.rb', line 54

def type= type_name
  self.type_id = type_name.card_id
end

#type_cardObject



32
33
34
# File 'platypus/tmp/set/gem-card/mod001-core/all/type.rb', line 32

def type_card
  Card.quick_fetch type_id.to_i unless type_id.nil?
end

#type_cardnameObject



50
51
52
# File 'platypus/tmp/set/gem-card/mod001-core/all/type.rb', line 50

def type_cardname
  type_card.try :name
end

#type_codeObject



36
37
38
# File 'platypus/tmp/set/gem-card/mod001-core/all/type.rb', line 36

def type_code
  Card::Codename[type_id.to_i]
end

#type_id=(card_or_id) ⇒ Object



58
59
60
# File 'platypus/tmp/set/gem-card/mod001-core/all/type.rb', line 58

def type_id= card_or_id
  write_card_or_id :type_id, card_or_id
end

#type_nameObject Also known as: type



40
41
42
# File 'platypus/tmp/set/gem-card/mod001-core/all/type.rb', line 40

def type_name
  type_card.try :name
end

#type_name_or_defaultObject



46
47
48
# File 'platypus/tmp/set/gem-card/mod001-core/all/type.rb', line 46

def type_name_or_default
  type_card.try(:name) || Card.default_type_id.cardname
end