Parent

ArrayFields::FieldSet

multiton cache of fields - wraps fields and fieldpos map to save memory

Attributes

fields[R]
fieldpos[R]

Public Class Methods

init_sets() click to toggle source
    # File lib/arrayfields.rb, line 18
18:         def init_sets
19:           @sets = {}
20:         end
new(fields) click to toggle source
    # File lib/arrayfields.rb, line 15
15:         def new fields
16:           @sets[fields] ||= super
17:         end
new(fields) click to toggle source
    # File lib/arrayfields.rb, line 27
27:       def initialize fields
28:         raise ArgumentError, "<#{ fields.inspect }> not inject-able" unless
29:           fields.respond_to? :inject
30: 
31:         @fieldpos =
32:           fields.inject({}) do |h, f|
33:             unless String === f or Symbol === f
34:               raise ArgumentError, "<#{ f.inspect }> neither String nor Symbol"
35:             end
36:             h[f] = h.size
37:             h
38:           end
39: 
40:         @fields = fields
41:       end

Public Instance Methods

pos(f) click to toggle source
    # File lib/arrayfields.rb, line 42
42:       def pos f
43:         return @fieldpos[f] if @fieldpos.has_key? f 
44:         f = f.to_s
45:         return @fieldpos[f] if @fieldpos.has_key? f 
46:         f = f.intern
47:         return @fieldpos[f] if @fieldpos.has_key? f 
48:         nil
49:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.