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

Extended by:
Card::Set
Defined in:
platypus/tmp/set/gem-card/mod001-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

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



14
# File 'platypus/tmp/set/gem-card/mod001-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

#altered?Boolean

Returns:

  • (Boolean)


105
106
107
# File 'platypus/tmp/set/gem-card/mod001-core/all/states.rb', line 105

def altered?
  !pristine?
end

#known?True/False

Returns:

  • (True/False)


72
73
74
# File 'platypus/tmp/set/gem-card/mod001-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 'platypus/tmp/set/gem-card/mod001-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)


93
94
95
96
97
98
99
100
101
102
103
# File 'platypus/tmp/set/gem-card/mod001-core/all/states.rb', line 93

def pristine?
  if new_card?
    true
  elsif subcards? && subcards.cards.find(&:altered?)
    false
  elsif (created_at == updated_at) && (creator_id == WagnBotID)
    true
  else
    !user_changes?
  end
end

#purityObject



84
85
86
87
88
89
90
# File 'platypus/tmp/set/gem-card/mod001-core/all/states.rb', line 84

def purity
  case
  when new?      then :new
  when pristine? then :pristine
  else                :altered
  end
end

#real?True/False

Returns:

  • (True/False)


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

def unknown?
  !known?
end

#user_changes?Boolean

Returns:

  • (Boolean)


109
110
111
# File 'platypus/tmp/set/gem-card/mod001-core/all/states.rb', line 109

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 'platypus/tmp/set/gem-card/mod001-core/all/states.rb', line 59

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