Class: Dynaload::Exported
- Inherits:
-
Hash
- Object
- Hash
- Dynaload::Exported
show all
- Defined in:
- lib/dynaload.rb,
lib/dynaload-0.2.1.rb
Constant Summary
collapse
- THINGS =
%w( classes modules objects )
Instance Method Summary
collapse
Constructor Details
#initialize(*a, &b) ⇒ Exported
Returns a new instance of Exported.
12
13
14
15
|
# File 'lib/dynaload.rb', line 12
def initialize *a, &b
super
THINGS.each{|thing| self[thing] = []}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *a, &b) ⇒ Object
16
17
18
|
# File 'lib/dynaload.rb', line 16
def method_missing m, *a, &b
self["#{ m }"] || super
end
|
Instance Method Details
#clear! ⇒ Object
22
23
24
25
|
# File 'lib/dynaload.rb', line 22
def clear!
THINGS.each{|thing| self[thing].clear}
self
end
|
#dup ⇒ Object
37
38
39
|
# File 'lib/dynaload.rb', line 37
def dup
THINGS.inject({}){|h,t| h[t] = self[t].dup}
end
|
#empty? ⇒ Boolean
19
20
21
|
# File 'lib/dynaload.rb', line 19
def empty?
THINGS.map{|thing| self[thing].empty?}.all?
end
|
#export(thing, attributes) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/dynaload.rb', line 26
def export thing, attributes
case thing
when Class
(self['classes'] << [thing, attributes]).uniq!
when Module
(self['modules'] << [thing, attributes]).uniq!
else
(self['objects'] << [thing, attributes]).uniq!
end
self
end
|