Class: Perron::Data::Proxy
- Inherits:
-
Object
- Object
- Perron::Data::Proxy
show all
- Includes:
- Enumerable
- Defined in:
- lib/perron/data/proxy.rb
Instance Method Summary
collapse
Constructor Details
#initialize(parts = []) ⇒ Proxy
8
9
10
11
|
# File 'lib/perron/data/proxy.rb', line 8
def initialize(parts = [])
@parts = parts
@data = data_for_proxy
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *arguments, &block) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/perron/data/proxy.rb', line 23
def method_missing(name, *arguments, &block)
raise ArgumentError, "Data access does not accept arguments" if arguments.any? || block
new_parts = @parts + [name.to_s]
identifier = File.join(*new_parts)
return Proxy.new(new_parts) if Perron::Data.directory?(identifier)
return Perron::Data.new(identifier) if Perron::Data.path_for(identifier)
super
end
|
Instance Method Details
#each(&block) ⇒ Object
13
|
# File 'lib/perron/data/proxy.rb', line 13
def each(&block) = @data.each(&block)
|
#inspect ⇒ Object
15
|
# File 'lib/perron/data/proxy.rb', line 15
def inspect = @data.inspect
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
17
18
19
20
21
|
# File 'lib/perron/data/proxy.rb', line 17
def respond_to_missing?(name, include_private = false)
identifier = File.join(*@parts, name.to_s)
Perron::Data.directory?(identifier) || Perron::Data.path_for(identifier) || super
end
|