Sha256: 44741c1efd94a4d1b5074a1d52b5ea647686700456eefbac4f5b6133af9f10fc

Contents?: true

Size: 992 Bytes

Versions: 13

Compression:

Stored size: 992 Bytes

Contents

def act &block
  @action ||= identify_action
  if ActManager.act_card
    add_to_act &block
  else
    start_new_act &block
  end
end

def start_new_act
  self.director = nil
  ActManager.run_act(self) do
    run_callbacks(:act) { yield }
  end
end

def add_to_act
  # if only_storage_phase is true then the card is already part of the act
  return yield if ActManager.act_card == self || only_storage_phase
  director.reset_stage
  director.update_card self
  self.only_storage_phase = true
  yield
end

module ClassMethods
  def create! opts
    card = Card.new opts
    card.act do
      card.save!
    end
    card
  end

  def create opts
    card = Card.new opts
    card.act do
      card.save
    end
    card
  end
end

def save!(*)
  act { super }
end

def save(*)
  act { super }
end

def valid?(*)
  act { super }
end

def update *args
  act { super }
end

def update! *args
  act { super }
end

alias_method :update_attributes, :update
alias_method :update_attributes!, :update!

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
card-1.99.5 mod/core/set/all/actify.rb
card-1.99.4 mod/core/set/all/actify.rb
card-1.99.3 mod/core/set/all/actify.rb
card-1.99.2 mod/core/set/all/actify.rb
card-1.99.1 mod/core/set/all/actify.rb
card-1.99.0 mod/core/set/all/actify.rb
card-1.98.3 mod/core/set/all/actify.rb
card-1.98.2 mod/core/set/all/actify.rb
card-1.98.1 mod/core/set/all/actify.rb
card-1.98.0 mod/core/set/all/actify.rb
card-1.97.0.1 mod/core/set/all/actify.rb
card-1.97.0 mod/core/set/all/actify.rb
card-1.96.8 mod/core/set/all/actify.rb