Module: Card::Set::Type::Cardtype

Extended by:
Card::Set
Defined in:
card/tmpsets/set/mod004-standard/type/cardtype.rb,
card/tmpsets/set/mod025-card-mod-follow/type/cardtype.rb,
card/tmpsets/set/mod035-card-mod-search/type/cardtype.rb,
card/tmpsets/set/mod002-core/type/cardtype.rb,
card/tmpsets/set/mod037-card-mod-rules/type/cardtype.rb,
card/tmpsets/set/mod007-card-mod-format/type/cardtype.rb,
card/tmpsets/set/mod026-card-mod-follow/type/cardtype.rb,
card/tmpsets/set/mod036-card-mod-search/type/cardtype.rb

Overview

Set: All “Cardtype” cards

Defined Under Namespace

Modules: HtmlFormat

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_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, #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 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 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 7

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

Instance Method Details

#cards_of_type_exist?Boolean

Returns:

  • (Boolean)


99
100
101
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 99

def cards_of_type_exist?
  !new_card? && Card.where(trash: false, type_id: id).exists?
end

#cql_contentObject



10
11
12
# File 'card/tmpsets/set/mod035-card-mod-search/type/cardtype.rb', line 10

def cql_content
  { type_id: id, sort: :name }
end

#create_ok?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 103

def create_ok?
  Card.new(type_id: id).ok? :create
end

#event: check_for_cards_of_typeObject



111
112
113
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 111

event :check_for_cards_of_type, after: :validate_delete do
  errors.add :cardtype, tr(:cards_exist, cardname: name) if cards_of_type_exist?
end

#event: check_for_cards_of_type_when_type_changedObject



115
116
117
118
119
120
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 115

event :check_for_cards_of_type_when_type_changed,
      :validate, changing: :type, when: :was_cardtype? do
  if cards_of_type_exist?
    errors.add :cardtype, tr(:error_cant_alter, name: name_before_act)
  end
end

#event: validate_cardtype_nameObject



122
123
124
125
126
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 122

event :validate_cardtype_name, :validate, on: :save, changed: :name do
  if %r{[<>/]}.match?(name)
    errors.add :name, tr(:error_invalid_character_in_cardtype, banned: "<, >, /")
  end
end

#follow_labelObject



8
9
10
# File 'card/tmpsets/set/mod025-card-mod-follow/type/cardtype.rb', line 8

def follow_label
  follow_set_card.follow_label
end

#follow_set_cardObject



16
17
18
# File 'card/tmpsets/set/mod025-card-mod-follow/type/cardtype.rb', line 16

def follow_set_card
  Card.fetch name, :type
end

#followed_by?(user_id = nil) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'card/tmpsets/set/mod025-card-mod-follow/type/cardtype.rb', line 12

def followed_by? user_id=nil
  follow_set_card.all_members_followed_by? user_id
end

#list_direct_followers?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'card/tmpsets/set/mod025-card-mod-follow/type/cardtype.rb', line 20

def list_direct_followers?
  true
end


8
9
10
11
12
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 8

def related_sets with_self=false
  sets = []
  sets << ["#{name}+*type", Card::Set::Type.label(name)] if known?
  sets + super
end

#was_cardtype?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'card/tmpsets/set/mod004-standard/type/cardtype.rb', line 107

def was_cardtype?
  type_id_before_act == Card::CardtypeID
end