Class: Effigy::ExampleElementTransformer

Inherits:
Object
  • Object
show all
Defined in:
lib/effigy/example_element_transformer.rb

Overview

Performs transformations based on an array of example elements. Used internally.

See Also:

Instance Method Summary (collapse)

Constructor Details

- (ExampleElementTransformer) initialize(view, example_elements)

A new instance of ExampleElementTransformer



5
6
7
8
# File 'lib/effigy/example_element_transformer.rb', line 5

def initialize(view, example_elements)
  @view = view
  @example_elements = example_elements
end

Instance Method Details

- (Object) replace_each(collection, &block)

Replaces the example elements with a clone for each item in the collection. Only the first example element will be used for cloning, but all example elements will be removed.

Parameters:

  • collection (Enumerable)

    the items that are the base for each cloned element



16
17
18
19
# File 'lib/effigy/example_element_transformer.rb', line 16

def replace_each(collection, &block)
  clone_and_transform_each(collection, &block)
  remove_all
end