Class: RoadForest::BlobModel
- Inherits:
-
Model
- Object
- Model
- RoadForest::BlobModel
show all
- Defined in:
- lib/roadforest/blob-model.rb
Constant Summary
collapse
- TypeHandlers =
RoadForest::MediaType::Handlers
Instance Attribute Summary
Attributes inherited from Model
#data, #params, #response_values, #route_name, #services
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Model
#add_child, #authentication_challenge, #authorization, #canonical_host, #canonical_uri, #delete, #etag, #exists?, #expires, #initialize, #last_modified, #model_for, #my_path, #my_url, #path_for, #processed, #required_grants, #reset, #response_data, #response_data=, #response_location, #response_location=, #url_for
Class Method Details
.add_type(handler, type) ⇒ Object
Also known as:
add
12
13
14
|
# File 'lib/roadforest/blob-model.rb', line 12
def add_type(handler, type)
type_handling.add_type(handler, type)
end
|
Instance Method Details
#destination_dir ⇒ Object
22
23
24
|
# File 'lib/roadforest/blob-model.rb', line 22
def destination_dir
Pathname.new(services.destination_dir)
end
|
#incomplete_path ⇒ Object
38
39
40
|
# File 'lib/roadforest/blob-model.rb', line 38
def incomplete_path
[path,"incomplete"].join(".")
end
|
#path ⇒ Object
30
31
32
|
# File 'lib/roadforest/blob-model.rb', line 30
def path
destination_dir.join(sub_path)
end
|
#retrieve ⇒ Object
34
35
36
|
# File 'lib/roadforest/blob-model.rb', line 34
def retrieve
File::open(path)
end
|
#sub_path ⇒ Object
26
27
28
|
# File 'lib/roadforest/blob-model.rb', line 26
def sub_path
params.remainder
end
|
#type_handling ⇒ Object
18
19
20
|
# File 'lib/roadforest/blob-model.rb', line 18
def type_handling
self.class.type_handling
end
|
#update(incoming) ⇒ Object
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/roadforest/blob-model.rb', line 42
def update(incoming)
File::open(incomplete_path, "w") do |file|
incoming.each do |chunk|
file.write(chunk)
end
end
Pathname.new(incomplete_path).rename(path)
return nil
end
|