class Mapper

Represents mapped objects holder.

Represents mapped objects holder.

Represents mapped objects holder.

Public Class Methods

[](*args) click to toggle source

Alias for new. @see {#initialize}

# File lib/mapper.rb, line 32
def self.[](*args)
    self::new(*args)
end
new(*objs) click to toggle source

Constructor.

If only one argument, and it’s Array, content will be treaten as matter for mapping.

# File lib/mapper.rb, line 43
def initialize(*objs)
    if (objs.length == 1) and (objs.first.kind_of? Array)
        self.merge! objs.first
    else
        self.merge! objs
    end
end

Public Instance Methods

all() click to toggle source

Produces reductor which passes call with given arguments to each object.

# File lib/mapper.rb, line 56
def all
    if @all.nil?
        @all = All::new(self)
    end
    
    return @all
end
some(&block) click to toggle source

Produces reductor which passes call with given arguments to each object from oldest to newest in aggregator if the output of given block isn’t true.

# File lib/mapper.rb, line 70
def some(&block)

    # Returns from cache
    if not @some.nil? and block.nil?
        return @some
    end

    # In otherwise, creates new
    default = false
    
    if block.nil?
        block = Proc::new { |v| v.to_b }
        default = true
    end

    some = Some::new(self, &block)
    
    if (default == true) and @some.nil?
        @some = some
    end
    
    return some
end