Module: Card::Set::Abstract::MachineInput
- Extended by:
- Card::Set
- Defined in:
- tmpsets/set/mod014-machines/abstract/machine_input.rb
Overview
Set: Abstract (MachineInput)
Defined Under Namespace
Modules: MachineInputClassMethods
Constant Summary
Constants included from Helpers
Helpers::SET_PATTERN_TEST_REGEXP
Class Method Summary collapse
- .define_delete_events(event_suffix, host_class) ⇒ Object
- .define_update_event(event_suffix, host_class) ⇒ Object
- .included(host_class) ⇒ Object
- .search_involved_machines(name, host_class) ⇒ Object
- .source_location ⇒ Object
Instance Method Summary collapse
Methods included from Card::Set
Methods included from I18nScope
Methods included from Loader
#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set
Methods included from Helpers
#method_missing, #num_set_parts, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscore
Methods included from Card::Set::AdvancedApi
#attachment, #ensure_set, #stage_method
Methods included from Format
#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name
Methods included from Inheritance
#include_set, #include_set_formats
Methods included from Basket
#abstract_basket, #add_to_basket, #basket, #unshift_basket
Methods included from Trait
#card_accessor, #card_reader, #card_writer, #require_field
Methods included from Event::Api
Class Method Details
.define_delete_events(event_suffix, host_class) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'tmpsets/set/mod014-machines/abstract/machine_input.rb', line 31 def self.define_delete_events event_suffix, host_class event_name = "before_machine_input_deleted_#{event_suffix}".to_sym host_class.event event_name, :store, on: :delete do # exclude self because it's on the way to the trash # otherwise it will be created again with the reset_machine_output # call in the event below @involved_machines = MachineInput.search_involved_machines(name, host_class) .reject { |card| card == self } end event_name = "after_machine_input_deleted_#{event_suffix}".to_sym host_class.event event_name, :finalize, on: :delete do expire_machine_cache @involved_machines.each do |item| item.reset_machine_output if item.is_a? Machine end end end |
.define_update_event(event_suffix, host_class) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'tmpsets/set/mod014-machines/abstract/machine_input.rb', line 50 def self.define_update_event event_suffix, host_class host_class.event( "after_machine_input_updated_#{event_suffix}".to_sym, :integrate, on: :save ) do expire_machine_cache MachineInput.search_involved_machines(name, host_class) .each do |item| item.reset_machine_output if item.is_a? Machine end end end |
.included(host_class) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'tmpsets/set/mod014-machines/abstract/machine_input.rb', line 20 def self.included host_class host_class.extend(MachineInputClassMethods) host_class.machines_wql = {} host_class.machine_input do format._render_raw end event_suffix = host_class.name.tr ":", "_" define_update_event event_suffix, host_class define_delete_events event_suffix, host_class end |
.search_involved_machines(name, host_class) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'tmpsets/set/mod014-machines/abstract/machine_input.rb', line 63 def self.search_involved_machines name, host_class wql_statement = { right_plus: [ { codename: "machine_input" }, { link_to: name } ] }.merge(host_class.machines_wql) Card.search(wql_statement) end |
.source_location ⇒ Object
7 |
# File 'tmpsets/set/mod014-machines/abstract/machine_input.rb', line 7 def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/machines/set/abstract/machine_input.rb"; end |
Instance Method Details
#expire_machine_cache ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'tmpsets/set/mod014-machines/abstract/machine_input.rb', line 72 def expire_machine_cache Card.search(right_plus: [{ codename: "machine_input" }, { link_to: name }], return: :name).each do |machine_name| cache_card = Card.fetch(name, machine_name, :machine_cache) next unless cache_card&.content? Auth.as_bot { cache_card.update! trash: true } end end |