Class: Valise::DefinedDefaults
Defined Under Namespace
Classes: DefinitionHelper
Class Method Summary
collapse
Instance Method Summary
collapse
#insert, #writable?, #write
Methods inherited from SearchRoot
#full_path, #insert, #inspect, #writable?, #write
Methods included from Unpath
#repath, #unpath
Constructor Details
Returns a new instance of DefinedDefaults.
91
92
93
|
# File 'lib/valise/search-root.rb', line 91
def initialize
@files = {}
end
|
Class Method Details
.define(&block) ⇒ Object
121
122
123
|
# File 'lib/valise/search-root.rb', line 121
def self.define(&block)
return self.new.define(&block)
end
|
Instance Method Details
#add_dir(path) ⇒ Object
136
137
138
|
# File 'lib/valise/search-root.rb', line 136
def add_dir(path)
end
|
#add_file(path, data = nil) ⇒ Object
140
141
142
|
# File 'lib/valise/search-root.rb', line 140
def add_file(path, data = nil)
add_item(path, data)
end
|
#add_item(path, contents) ⇒ Object
125
126
127
128
129
130
131
132
133
134
|
# File 'lib/valise/search-root.rb', line 125
def add_item(path, contents)
check_path = path[0..-2]
until check_path.empty?
if @files.has_key?(check_path)
raise Errors::MalformedTree, "Tried to add items below #{path[0..-2]} which is not a directory"
end
check_path.pop
end
@files[path] = contents
end
|
#define(&block) ⇒ Object
113
114
115
116
117
118
119
|
# File 'lib/valise/search-root.rb', line 113
def define(&block)
unless block.nil?
definer = DefinitionHelper.new(self)
definer.instance_eval &block
end
return self
end
|
#each ⇒ Object
103
104
105
106
107
|
# File 'lib/valise/search-root.rb', line 103
def each
@files.each_key do |path|
yield(unpath(path))
end
end
|
#get_from(item) ⇒ Object
109
110
111
|
# File 'lib/valise/search-root.rb', line 109
def get_from(item)
return @files[item.segments]
end
|
#present?(segments) ⇒ Boolean
99
100
101
|
# File 'lib/valise/search-root.rb', line 99
def present?(segments)
@files.has_key?(segments)
end
|
#segments ⇒ Object
95
96
97
|
# File 'lib/valise/search-root.rb', line 95
def segments
raise Errors::VirtualSearchPath, "does not have a real path"
end
|