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, #to_s, #writable?, #write
Methods included from Unpath
#collapse, #repath, #string_to_segments, #unpath
Constructor Details
Returns a new instance of DefinedDefaults.
95
96
97
|
# File 'lib/valise/search-root.rb', line 95
def initialize
@files = {}
end
|
Class Method Details
.define(&block) ⇒ Object
125
126
127
|
# File 'lib/valise/search-root.rb', line 125
def self.define(&block)
return self.new.define(&block)
end
|
Instance Method Details
#add_dir(path) ⇒ Object
140
141
142
|
# File 'lib/valise/search-root.rb', line 140
def add_dir(path)
end
|
#add_file(path, data = nil) ⇒ Object
144
145
146
|
# File 'lib/valise/search-root.rb', line 144
def add_file(path, data = nil)
add_item(path, data)
end
|
#add_item(path, contents) ⇒ Object
129
130
131
132
133
134
135
136
137
138
|
# File 'lib/valise/search-root.rb', line 129
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
117
118
119
120
121
122
123
|
# File 'lib/valise/search-root.rb', line 117
def define(&block)
unless block.nil?
definer = DefinitionHelper.new(self)
definer.instance_eval &block
end
return self
end
|
#each ⇒ Object
107
108
109
110
111
|
# File 'lib/valise/search-root.rb', line 107
def each
@files.each_key do |path|
yield(unpath(path))
end
end
|
#get_from(item) ⇒ Object
113
114
115
|
# File 'lib/valise/search-root.rb', line 113
def get_from(item)
return @files[item.segments]
end
|
#present?(segments) ⇒ Boolean
103
104
105
|
# File 'lib/valise/search-root.rb', line 103
def present?(segments)
@files.has_key?(segments)
end
|
#segments ⇒ Object
99
100
101
|
# File 'lib/valise/search-root.rb', line 99
def segments
raise Errors::VirtualSearchPath, "does not have a real path"
end
|