Method: JSI::Util#modified_copy

Defined in:
lib/jsi/util.rb

#modified_copy(object) {|Object| ... } ⇒ object.class

yields the content of the given param object. for objects which have a #jsi_modified_copy method of their own (JSI::Base, JSI::MetaSchemaNode) that method is invoked with the given block. otherwise the given object itself is yielded.

the given block must result in a modified copy of its block parameter (not destructively modifying the yielded content).

Yields:

  • (Object)

    the content of the given object. the block should result in a (nondestructively) modified copy of this.

Returns:

  • (object.class)

    modified copy of the given object



25
26
27
28
29
30
31
# File 'lib/jsi/util.rb', line 25

def modified_copy(object, &block)
  if object.respond_to?(:jsi_modified_copy)
    object.jsi_modified_copy(&block)
  else
    yield(object)
  end
end