Module: Qwe::Proxy
- Defined in:
- lib/qwe/proxy.rb
Defined Under Namespace
Class Method Summary collapse
Class Method Details
.block(klass, *methods) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/qwe/proxy.rb', line 26 def self.block(klass, *methods) methods.each do |m| klass.define_method(m) do |*a, **k, &block| r = super(*a, **k, &block) if block __qwe_thing&.root&.record&.commit "#{__qwe_thing.to_rb}.instance_variable_set(:@#{__qwe_name}, #{to_rb})\n" else __qwe_commit(m, *a, **k) end r end end end |
.make(klass) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/qwe/proxy.rb', line 3 def self.make(klass) klass.module_exec do attr_accessor :__qwe_thing, :__qwe_name include DRb::DRbUndumped undef _dump def __qwe_commit(m, *a, **k) __qwe_thing&.root&.record&.commit("#{__qwe_thing.to_rb}.#{__qwe_name}.method(:#{m}).super_method.call(*#{a.to_rb}, **#{k.to_rb})\n") end end end |
.transaction(klass, *methods) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/qwe/proxy.rb', line 17 def self.transaction(klass, *methods) methods.each do |m| klass.define_method(m) do |*a, **k| __qwe_commit(m, *a, **k) super(*a, **k) end end end |