Sha256: 57f81be83bb71d97b2fca03be7002b6aa3c669ee17426edd0058ee0b0980ccb3

Contents?: true

Size: 1.38 KB

Versions: 30

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

30 entries across 30 versions & 2 rubygems

Version Path
card-1.16.6 mod/03_machines/lib/card/machine_input.rb
card-1.16.5 mod/03_machines/lib/card/machine_input.rb
card-1.16.4 mod/03_machines/lib/card/machine_input.rb
card-1.16.3 mod/03_machines/lib/card/machine_input.rb
card-1.16.2 mod/03_machines/lib/card/machine_input.rb
card-1.16.1 mod/03_machines/lib/card/machine_input.rb
card-1.16.0 mod/03_machines/lib/card/machine_input.rb
card-1.15.7 mod/03_machines/lib/card/machine_input.rb
card-1.15.6 mod/03_machines/lib/card/machine_input.rb
card-1.15.5 mod/03_machines/lib/card/machine_input.rb
card-1.15.4 mod/03_machines/lib/card/machine_input.rb
card-1.15.3 mod/03_machines/lib/card/machine_input.rb
card-1.15.2 mod/03_machines/lib/card/machine_input.rb
card-1.15.1 mod/03_machines/lib/card/machine_input.rb
card-1.15.0 mod/03_machines/lib/card/machine_input.rb
card-1.15.pre2 mod/03_machines/lib/card/machine_input.rb
card-1.15.pre mod/03_machines/lib/card/machine_input.rb
wagn-1.14.9 mod/03_machines/lib/card/machine_input.rb
wagn-1.14.8 mod/03_machines/lib/card/machine_input.rb
wagn-1.14.7 mod/03_machines/lib/card/machine_input.rb