Sha256: 5364acafab4b6eb15bb9e2f6af06ba5b5d5d0c36119d7f84b49f273210cb1c29

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

class Card
  class Director
    # director-related Card instance methods
    module All
      def act options={}, &block
        if act_card
          add_to_act options, &block
        else
          start_new_act(&block)
        end
      end

      def act_card
        Card::Director.act_card
      end

      def act_card?
        self == act_card
      end

      def save! **args
        as_subcard = args.delete :as_subcard
        act(as_subcard: as_subcard) { super **args }
      end

      def save *args
        act { super }
      end

      def valid? *args
        act(validating: true) { super }
      end

      def update *args
        act { super }
      end

      def update! *args
        act { super }
      end

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

      private

      def start_new_act &block
        self.director = nil
        Director.run_act(self) do
          run_callbacks(:act, &block)
        end
      end

      def add_to_act options={}
        director.appoint self unless @director
        director.head = true unless options[:validating] || options[:as_subcard]
        yield
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
card-1.102.0 lib/card/director/all.rb