Sha256: 114bdb44e4640a193d743404dfb1b92357f52e4b4bb45f1731d6100fcae652e7

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

class Card
  module MachineInput
    module ClassMethods
      attr_accessor :machines_wql
    
      def machine_input_for args
        @machines_wql = args
      end
    
      def machine_input &block
        define_method :machine_input, block
      end
    end
  
    def self.included host_class
      host_class.extend( ClassMethods )
      host_class.machines_wql = {}
      host_class.machine_input do
        format._render_raw
      end
      host_class.event "after_machine_input_updated_#{host_class.name.gsub(':','_')}".to_sym, :after=>:extend, :on => :save do
        machines = Card.search( {:right_plus => [{:codename => "machine_input"}, {:link_to => name}]}.merge(host_class.machines_wql) )  
        machines.each do |item|
          item.reset_machine_output! if item.kind_of? Machine
        end
      end
    
      host_class.event "before_machine_input_deleted_#{host_class.name.gsub(':','_')}".to_sym, :after=>:approve, :on => :delete do
        @involved_machines = Card.search( {:right_plus => [{:codename => "machine_input"}, {:link_to => name}]}.merge(host_class.machines_wql) )  
      end
    
      host_class.event "after_machine_input_deleted_#{host_class.name.gsub(':','_')}".to_sym, :after=>:store_subcards, :on => :delete do
        @involved_machines.each do |item|
          item.reset_machine_output! if item.kind_of? Machine
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wagn-1.13.0 mod/standard/lib/card/machine_input.rb