Class: One::Pivot

Inherits:
Object
  • Object
show all
Defined in:
lib/one/pivot.rb

Overview

Simple class to hold meta information about a pivot. This class was created to support invoking One::Pivot#multi_pivot with identifiers for each pivot.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier) {|item| ... } ⇒ Pivot

Constructor. param [String, Symbol] identifier The name of the pivot

Yields:

  • (item)

    This block will be called for each item in the list when pivot is invoked

Yield Parameters:

  • item (Object)

    An item in the list

Yield Returns:

  • (Object)

    The value returned from the pivot block will serve as the key in the pivot results

Raises:

  • (LocalJumpError)


14
15
16
17
18
# File 'lib/one/pivot.rb', line 14

def initialize(identifier, &block)
  raise LocalJumpError.new("no block given") unless block_given?
  @identifier = identifier
  @pivot_proc = block
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



6
7
8
# File 'lib/one/pivot.rb', line 6

def identifier
  @identifier
end

#pivot_procObject (readonly)

Returns the value of attribute pivot_proc.



7
8
9
# File 'lib/one/pivot.rb', line 7

def pivot_proc
  @pivot_proc
end