Module: Card::Set::All::States

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

Overview

etc. But we don't store all these cards in the database; we generate them dynamically

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

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

#abstract_set?, #all_set?, #num_set_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



14
# File 'tmpsets/set/mod003-core/all/states.rb', line 14

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

Instance Method Details

#known?True/False

Returns:

  • (True/False)


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

def known?
  real? || virtual?
end

#new?True/False Also known as: new_card?, unreal?

Returns:

  • (True/False)


77
78
79
80
# File 'tmpsets/set/mod003-core/all/states.rb', line 77

def new?
  new_record? ||       # not yet in db (from ActiveRecord)
    !@from_trash.nil?  # in process of restoration from trash
end

#pristine?Boolean

has not been edited directly by human users. bleep blorp.

Returns:

  • (Boolean)


85
86
87
88
89
# File 'tmpsets/set/mod003-core/all/states.rb', line 85

def pristine?
  new_card? || !actions.joins(:act).where(
    "card_acts.actor_id != ?", Card::WagnBotID
  ).exists?
end

#real?True/False

Returns:

  • (True/False)


47
48
49
# File 'tmpsets/set/mod003-core/all/states.rb', line 47

def real?
  !unreal?
end

#state(anti_fishing = true) ⇒ Symbol

Returns :real, :virtual, or :unknown.

Returns:

  • (Symbol)

    :real, :virtual, or :unknown



36
37
38
39
40
41
42
43
44
# File 'tmpsets/set/mod003-core/all/states.rb', line 36

def state anti_fishing=true
  case
  when !known?                     then :unknown
  when anti_fishing && !ok?(:read) then :unknown
  when real?                       then :real
  when virtual?                    then :virtual
  else :wtf
  end
end

#unknown?True/False

Returns:

  • (True/False)


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

def unknown?
  !known?
end

#virtual?True/False

Virtual cards are structured, compound cards that are not stored in the database. You can create virtual cards with structure rules.

Some cards with hard-coded content will also override the #virtual? method. This is established practice, but it is NOT advisable to override any of the other state methods.

Returns:

  • (True/False)


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

def virtual?
  if @virtual.nil?
    @virtual = real? || name.simple? ? false : structure.present?
  end
  @virtual
end