Module: PGB::Mutable
- Included in:
- Query
- Defined in:
- lib/pgb/mutable.rb
Instance Method Summary collapse
Instance Method Details
#mutable(method) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/pgb/mutable.rb', line 5 def mutable(method) original_method = "original_#{method}" alias_method original_method, method define_method("#{method}!") do |*args, **opts, &block| public_send(original_method, *args, **opts, &block) self end define_method(method) do |*args, **opts, &block| copy = dup copy.instance_exec { public_send(original_method, *args, **opts, &block) } copy end end |