Sha256: b2e1c568ab9775293112fd0c36f4d033c93064113c2cea73af26a9c60f73bb9c

Contents?: true

Size: 836 Bytes

Versions: 30

Compression:

Stored size: 836 Bytes

Contents

module ClassMethods
  def exists? mark
    card = quick_fetch mark
    card.present?
  end
  alias :exist? :exists?

  def known? mark
    card = fetch mark, skip_modules: true
    card.present?
  end
end

def state
  case
  when !known?     then :unknown
  when !ok?(:read) then :unknown # anti-fishing
  when real?       then :real
  when virtual?    then :virtual
  else :wtf
  end
end

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

def known?
  real? || virtual?
end

def real?
  !new_card?
end

def unknown?
  !known?
end

def pristine?
  # has not been edited directly by human users.  bleep blorp.
  new_card? || !actions.joins(:act).where(
    "card_acts.actor_id != ?", Card::WagnBotID
  ).exists?
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
card-1.97.0.1 mod/core/set/all/states.rb
card-1.97.0 mod/core/set/all/states.rb
card-1.96.8 mod/core/set/all/states.rb
card-1.96.7 mod/core/set/all/states.rb
card-1.96.6 mod/core/set/all/states.rb
card-1.96.5 mod/core/set/all/states.rb
card-1.96.4 mod/core/set/all/states.rb
card-1.96.3 mod/core/set/all/states.rb
card-1.96.2 mod/core/set/all/states.rb
card-1.96.1 mod/core/set/all/states.rb
card-1.96.0 mod/core/set/all/states.rb
card-1.95.3 mod/core/set/all/states.rb
card-1.95.2 mod/core/set/all/states.rb
card-1.95.1 mod/core/set/all/states.rb
card-1.95.0 mod/core/set/all/states.rb
card-1.94.1 mod/core/set/all/states.rb
card-1.94.0 mod/core/set/all/states.rb
card-1.93.13 mod/core/set/all/states.rb
card-1.93.12 mod/core/set/all/states.rb
card-1.93.11 mod/core/set/all/states.rb