Class: Annotations::Annotator

Inherits:
Object
  • Object
show all
Defined in:
lib/spiderfw/utils/annotations.rb

Instance Method Summary collapse

Constructor Details

#initialize(owner) ⇒ Annotator

Returns a new instance of Annotator.



70
71
72
73
74
75
76
# File 'lib/spiderfw/utils/annotations.rb', line 70

def initialize(owner) 
    @owner = owner
    @annotations = {}
    @pending_annotations = []
    @m_pending_annotations = []
    @pending = @pending_annotations
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



87
88
89
# File 'lib/spiderfw/utils/annotations.rb', line 87

def method_missing(name, *args)
    @pending << [name, args]
end

Instance Method Details

#annotate(method_name, *args) ⇒ Object



91
92
93
# File 'lib/spiderfw/utils/annotations.rb', line 91

def annotate(method_name, *args)
    @owner.annotations[method_name] = args
end

#clear_pendingObject



83
84
85
# File 'lib/spiderfw/utils/annotations.rb', line 83

def clear_pending
    @pending_annotations.clear
end

#multipleObject



100
101
102
103
# File 'lib/spiderfw/utils/annotations.rb', line 100

def multiple
    @pending = @m_pending_annotations
    return self
end

#pendingObject



78
79
80
81
# File 'lib/spiderfw/utils/annotations.rb', line 78

def pending
    r = @m_pending_annotations + @pending_annotations
    return r
end

#singleObject



95
96
97
98
# File 'lib/spiderfw/utils/annotations.rb', line 95

def single
    @pending = @pending_annotations
    return self
end