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

Extended by:
Card::Set
Defined in:
card/tmpsets/set/mod002-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

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

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



14
# File 'card/tmpsets/set/mod002-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 'card/tmpsets/set/mod002-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 'card/tmpsets/set/mod002-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
# File 'card/tmpsets/set/mod002-core/all/states.rb', line 85

def pristine?
  new_card? || !user_changes?
end

#real?True/False

Returns:

  • (True/False)


47
48
49
# File 'card/tmpsets/set/mod002-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 'card/tmpsets/set/mod002-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 'card/tmpsets/set/mod002-core/all/states.rb', line 67

def unknown?
  !known?
end

#user_changes?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'card/tmpsets/set/mod002-core/all/states.rb', line 89

def user_changes?
  actions.joins(:act).where("card_acts.actor_id != ?", WagnBotID).exists?
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 'card/tmpsets/set/mod002-core/all/states.rb', line 59

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