Class: ODDB::Util::AnnotatedList

Inherits:
Array
  • Object
show all
Defined in:
lib/oddb/util/annotated_list.rb

Instance Method Summary collapse

Constructor Details

#initialize(annotations = {}) ⇒ AnnotatedList

Returns a new instance of AnnotatedList.



7
8
9
10
11
12
13
14
15
# File 'lib/oddb/util/annotated_list.rb', line 7

def initialize(annotations = {})
  if(annotations.is_a?(Hash))
    super()
    @annotations = annotations
  else
    super
    @annotations = {}
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(key, *args) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/oddb/util/annotated_list.rb', line 22

def method_missing(key, *args)
  mname = key.id2name
  if(args.size == 1 && /=$/.match(mname))
    mname.chop!
    @annotations[mname.to_sym] = args.first
  else
    @annotations[key]
  end
end

Instance Method Details

#[](*args, &block) ⇒ Object



19
20
21
# File 'lib/oddb/util/annotated_list.rb', line 19

def [](*args, &block)
  _delegate(super(*args, &block))
end

#sort_by(*args, &block) ⇒ Object



16
17
18
# File 'lib/oddb/util/annotated_list.rb', line 16

def sort_by(*args, &block)
  _delegate(super(*args, &block))
end