Module: GQL::Mixins::Common
- Included in:
- Field
- Defined in:
- lib/gql/mixins/common.rb
Instance Method Summary collapse
Instance Method Details
#propagate(type, id, klass) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/gql/mixins/common.rb', line 7 def propagate(type, id, klass) const_name = send("const_name_for_#{type}", id) accessor = type.to_s.pluralize const_set const_name, klass [self, *descendants].each do |c| c.send "#{accessor}=", c.send(accessor).merge(id => klass) end end |
#shutdown(type, id) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gql/mixins/common.rb', line 18 def shutdown(type, id) const_name = send("const_name_for_#{type}", id) accessor = type.to_s.pluralize [self, *descendants].each do |c| next unless c.send("has_#{type}?", id) c.send :remove_const, const_name if c.const_defined?(const_name, false) c.send(accessor).delete id end end |